Update auto-generated bindings to 0.0.102
[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 ((unsigned 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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_result_ok(uint32_t arg) {
2227         return ((LDKCResult_PaymentIdDecodeErrorZ*)arg)->result_ok;
2228 }
2229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_get_ok(uint32_t arg) {
2230         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
2231         CHECK(val->result_ok);
2232         LDKPaymentId res_var = (*val->contents.result);
2233         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2234         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2235         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2236         return res_ref;
2237 }
2238 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdDecodeErrorZ_get_err(uint32_t arg) {
2239         LDKCResult_PaymentIdDecodeErrorZ *val = (LDKCResult_PaymentIdDecodeErrorZ*)(arg & ~1);
2240         CHECK(!val->result_ok);
2241         LDKDecodeError err_var = (*val->contents.err);
2242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2245         return err_ref;
2246 }
2247 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2248         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2249         switch(obj->tag) {
2250                 case LDKCOption_u16Z_Some: {
2251                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2252                 }
2253                 case LDKCOption_u16Z_None: {
2254                         return 0 /* LDKCOption_u16Z - None */;
2255                 }
2256                 default: abort();
2257         }
2258 }
2259 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2260         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2261         switch(obj->tag) {
2262                 case LDKAPIError_APIMisuseError: {
2263                         LDKStr err_str = obj->api_misuse_error.err;
2264                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2265                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2266                 }
2267                 case LDKAPIError_FeeRateTooHigh: {
2268                         LDKStr err_str = obj->fee_rate_too_high.err;
2269                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2270                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2271                 }
2272                 case LDKAPIError_RouteError: {
2273                         LDKStr err_str = obj->route_error.err;
2274                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2275                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2276                 }
2277                 case LDKAPIError_ChannelUnavailable: {
2278                         LDKStr err_str = obj->channel_unavailable.err;
2279                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2280                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2281                 }
2282                 case LDKAPIError_MonitorUpdateFailed: {
2283                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2284                 }
2285                 case LDKAPIError_IncompatibleShutdownScript: {
2286                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2287                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2288                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2289                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
2290                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2291                 }
2292                 default: abort();
2293         }
2294 }
2295 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2296         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2297 }
2298 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2299         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2300         CHECK(val->result_ok);
2301         return *val->contents.result;
2302 }
2303 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2304         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2305         CHECK(!val->result_ok);
2306         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2307         return err_ref;
2308 }
2309 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2310         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2311         ret->datalen = *((uint32_t*)elems);
2312         if (ret->datalen == 0) {
2313                 ret->data = NULL;
2314         } else {
2315                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2316                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2317                 for (size_t i = 0; i < ret->datalen; i++) {
2318                         uint32_t arr_elem = java_elems[i];
2319                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2320                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2321                         ret->data[i] = arr_elem_conv;
2322                 }
2323         }
2324         return (uint64_t)ret;
2325 }
2326 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2327         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2328         for (size_t i = 0; i < ret.datalen; i++) {
2329                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2330         }
2331         return ret;
2332 }
2333 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2334         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2335         ret->datalen = *((uint32_t*)elems);
2336         if (ret->datalen == 0) {
2337                 ret->data = NULL;
2338         } else {
2339                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2340                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2341                 for (size_t i = 0; i < ret->datalen; i++) {
2342                         uint32_t arr_elem = java_elems[i];
2343                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2344                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2345                         ret->data[i] = arr_elem_conv;
2346                 }
2347         }
2348         return (uint64_t)ret;
2349 }
2350 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2351         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2352         for (size_t i = 0; i < ret.datalen; i++) {
2353                 ret.data[i] = APIError_clone(&orig->data[i]);
2354         }
2355         return ret;
2356 }
2357 jboolean  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_result_ok(uint32_t arg) {
2358         return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
2359 }
2360 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_ok(uint32_t arg) {
2361         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2362         CHECK(val->result_ok);
2363         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2364         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2365         return res_arr;
2366 }
2367 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_err(uint32_t arg) {
2368         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2369         CHECK(!val->result_ok);
2370         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2371         return err_ref;
2372 }
2373 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2374         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2375         switch(obj->tag) {
2376                 case LDKPaymentSendFailure_ParameterError: {
2377                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2378                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2379                 }
2380                 case LDKPaymentSendFailure_PathParameterError: {
2381                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2382                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2383                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2384                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2385                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2386                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2387                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2388                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2389                         }
2390                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2391                 }
2392                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2393                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2394                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2395                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2396                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2397                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2398                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2399                         }
2400                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2401                 }
2402                 case LDKPaymentSendFailure_PartialFailure: {
2403                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2404                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2405                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2406                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2407                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2408                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2409                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2410                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2411                         }
2412                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2413                 }
2414                 default: abort();
2415         }
2416 }
2417 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(uint32_t arg) {
2418         return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
2419 }
2420 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
2421         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2422         CHECK(val->result_ok);
2423         LDKPaymentId res_var = (*val->contents.result);
2424         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2425         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2426         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2427         return res_ref;
2428 }
2429 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
2430         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2431         CHECK(!val->result_ok);
2432         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2433         return err_ref;
2434 }
2435 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2436         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2437 }
2438 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2439         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2440         CHECK(val->result_ok);
2441         return *val->contents.result;
2442 }
2443 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2444         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2445         CHECK(!val->result_ok);
2446         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2447         return err_ref;
2448 }
2449 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
2450         LDKC2Tuple_PaymentHashPaymentIdZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
2451         LDKThirtyTwoBytes a_ref;
2452         CHECK(*((uint32_t*)a) == 32);
2453         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2454         ret->a = a_ref;
2455         LDKPaymentId b_conv;
2456         b_conv.inner = (void*)(b & (~1));
2457         b_conv.is_owned = (b & 1) || (b == 0);
2458         b_conv = PaymentId_clone(&b_conv);
2459         ret->b = b_conv;
2460         return (uint64_t)ret;
2461 }
2462 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2463         return ThirtyTwoBytes_clone(&tuple->a);
2464 }
2465 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t tuple) {
2466         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2467         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2468         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data, 32);
2469         return ret_arr;
2470 }
2471
2472 static inline struct LDKPaymentId C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2473         return PaymentId_clone(&tuple->b);
2474 }
2475 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
2476         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2477         LDKPaymentId ret_var = C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv);
2478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2480         uint64_t ret_ref = (uint64_t)ret_var.inner;
2481         if (ret_var.is_owned) {
2482                 ret_ref |= 1;
2483         }
2484         return ret_ref;
2485 }
2486
2487 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(uint32_t arg) {
2488         return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
2489 }
2490 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t arg) {
2491         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2492         CHECK(val->result_ok);
2493         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
2494         *res_conv = (*val->contents.result);
2495         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
2496         return ((uint64_t)res_conv);
2497 }
2498 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t arg) {
2499         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2500         CHECK(!val->result_ok);
2501         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2502         return err_ref;
2503 }
2504 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2505         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2506         switch(obj->tag) {
2507                 case LDKNetAddress_IPv4: {
2508                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2509                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2510                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2511                 }
2512                 case LDKNetAddress_IPv6: {
2513                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2514                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2515                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2516                 }
2517                 case LDKNetAddress_OnionV2: {
2518                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2519                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2520                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2521                 }
2522                 case LDKNetAddress_OnionV3: {
2523                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2524                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2525                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2526                 }
2527                 default: abort();
2528         }
2529 }
2530 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2531         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2532         ret->datalen = *((uint32_t*)elems);
2533         if (ret->datalen == 0) {
2534                 ret->data = NULL;
2535         } else {
2536                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2537                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2538                 for (size_t i = 0; i < ret->datalen; i++) {
2539                         uint32_t arr_elem = java_elems[i];
2540                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2541                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2542                         ret->data[i] = arr_elem_conv;
2543                 }
2544         }
2545         return (uint64_t)ret;
2546 }
2547 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2548         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2549         for (size_t i = 0; i < ret.datalen; i++) {
2550                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2551         }
2552         return ret;
2553 }
2554 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2555         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2556         LDKThirtyTwoBytes a_ref;
2557         CHECK(*((uint32_t*)a) == 32);
2558         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2559         ret->a = a_ref;
2560         LDKThirtyTwoBytes b_ref;
2561         CHECK(*((uint32_t*)b) == 32);
2562         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2563         ret->b = b_ref;
2564         return (uint64_t)ret;
2565 }
2566 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2567         return ThirtyTwoBytes_clone(&tuple->a);
2568 }
2569 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
2570         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2571         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2572         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
2573         return ret_arr;
2574 }
2575
2576 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2577         return ThirtyTwoBytes_clone(&tuple->b);
2578 }
2579 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
2580         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2581         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2582         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
2583         return ret_arr;
2584 }
2585
2586 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2587         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2588 }
2589 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2590         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2591         CHECK(val->result_ok);
2592         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2593         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2594         return res_arr;
2595 }
2596 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2597         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2598         CHECK(!val->result_ok);
2599         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2600         return err_ref;
2601 }
2602 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2603         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2604         ret->datalen = *((uint32_t*)elems);
2605         if (ret->datalen == 0) {
2606                 ret->data = NULL;
2607         } else {
2608                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2609                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2610                 for (size_t i = 0; i < ret->datalen; i++) {
2611                         uint32_t arr_elem = java_elems[i];
2612                         LDKChannelMonitor arr_elem_conv;
2613                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2614                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2615                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2616                         ret->data[i] = arr_elem_conv;
2617                 }
2618         }
2619         return (uint64_t)ret;
2620 }
2621 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2622         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2623         for (size_t i = 0; i < ret.datalen; i++) {
2624                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2625         }
2626         return ret;
2627 }
2628 typedef struct LDKWatch_JCalls {
2629         atomic_size_t refcnt;
2630         uint32_t watch_channel_meth;
2631         uint32_t update_channel_meth;
2632         uint32_t release_pending_monitor_events_meth;
2633 } LDKWatch_JCalls;
2634 static void LDKWatch_JCalls_free(void* this_arg) {
2635         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2636         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2637                 js_free(j_calls->watch_channel_meth);
2638                 js_free(j_calls->update_channel_meth);
2639                 js_free(j_calls->release_pending_monitor_events_meth);
2640                 FREE(j_calls);
2641         }
2642 }
2643 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2644         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2645         LDKOutPoint funding_txo_var = funding_txo;
2646         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2647         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2648         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2649         if (funding_txo_var.is_owned) {
2650                 funding_txo_ref |= 1;
2651         }
2652         LDKChannelMonitor monitor_var = monitor;
2653         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2654         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2655         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2656         if (monitor_var.is_owned) {
2657                 monitor_ref |= 1;
2658         }
2659         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2660         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2661         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2662         return ret_conv;
2663 }
2664 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2665         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2666         LDKOutPoint funding_txo_var = funding_txo;
2667         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2668         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2669         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2670         if (funding_txo_var.is_owned) {
2671                 funding_txo_ref |= 1;
2672         }
2673         LDKChannelMonitorUpdate update_var = update;
2674         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2675         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2676         uint64_t update_ref = (uint64_t)update_var.inner;
2677         if (update_var.is_owned) {
2678                 update_ref |= 1;
2679         }
2680         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2681         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2682         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2683         return ret_conv;
2684 }
2685 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2686         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2687         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2688         LDKCVec_MonitorEventZ ret_constr;
2689         ret_constr.datalen = *((uint32_t*)ret);
2690         if (ret_constr.datalen > 0)
2691                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2692         else
2693                 ret_constr.data = NULL;
2694         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2695         for (size_t o = 0; o < ret_constr.datalen; o++) {
2696                 uint32_t ret_conv_14 = ret_vals[o];
2697                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2698                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2699                 ret_constr.data[o] = ret_conv_14_conv;
2700         }
2701         return ret_constr;
2702 }
2703 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2704         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2705         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2706 }
2707 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2708         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2709         atomic_init(&calls->refcnt, 1);
2710         //TODO: Assign calls->o from o
2711
2712         LDKWatch ret = {
2713                 .this_arg = (void*) calls,
2714                 .watch_channel = watch_channel_LDKWatch_jcall,
2715                 .update_channel = update_channel_LDKWatch_jcall,
2716                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2717                 .free = LDKWatch_JCalls_free,
2718         };
2719         return ret;
2720 }
2721 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2722         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2723         *res_ptr = LDKWatch_init(o);
2724         return (long)res_ptr;
2725 }
2726 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2727         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2728         LDKOutPoint funding_txo_conv;
2729         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2730         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2731         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2732         LDKChannelMonitor monitor_conv;
2733         monitor_conv.inner = (void*)(monitor & (~1));
2734         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2735         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2736         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2737         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2738         return (uint64_t)ret_conv;
2739 }
2740
2741 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2742         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2743         LDKOutPoint funding_txo_conv;
2744         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2745         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2746         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2747         LDKChannelMonitorUpdate update_conv;
2748         update_conv.inner = (void*)(update & (~1));
2749         update_conv.is_owned = (update & 1) || (update == 0);
2750         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2751         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2752         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2753         return (uint64_t)ret_conv;
2754 }
2755
2756 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2757         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2758         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2759         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2760         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2761         for (size_t o = 0; o < ret_var.datalen; o++) {
2762                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2763                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2764                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2765                 ret_arr_ptr[o] = ret_conv_14_ref;
2766         }
2767         FREE(ret_var.data);
2768         return ret_arr;
2769 }
2770
2771 typedef struct LDKBroadcasterInterface_JCalls {
2772         atomic_size_t refcnt;
2773         uint32_t broadcast_transaction_meth;
2774 } LDKBroadcasterInterface_JCalls;
2775 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2776         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2777         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2778                 js_free(j_calls->broadcast_transaction_meth);
2779                 FREE(j_calls);
2780         }
2781 }
2782 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2783         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2784         LDKTransaction tx_var = tx;
2785         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2786         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2787         Transaction_free(tx_var);
2788         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2789 }
2790 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
2791         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
2792         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2793 }
2794 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2795         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2796         atomic_init(&calls->refcnt, 1);
2797         //TODO: Assign calls->o from o
2798
2799         LDKBroadcasterInterface ret = {
2800                 .this_arg = (void*) calls,
2801                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2802                 .free = LDKBroadcasterInterface_JCalls_free,
2803         };
2804         return ret;
2805 }
2806 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2807         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2808         *res_ptr = LDKBroadcasterInterface_init(o);
2809         return (long)res_ptr;
2810 }
2811 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2812         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2813         LDKTransaction tx_ref;
2814         tx_ref.datalen = *((uint32_t*)tx);
2815         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2816         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2817         tx_ref.data_is_owned = true;
2818         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2819 }
2820
2821 typedef struct LDKKeysInterface_JCalls {
2822         atomic_size_t refcnt;
2823         uint32_t get_node_secret_meth;
2824         uint32_t get_destination_script_meth;
2825         uint32_t get_shutdown_scriptpubkey_meth;
2826         uint32_t get_channel_signer_meth;
2827         uint32_t get_secure_random_bytes_meth;
2828         uint32_t read_chan_signer_meth;
2829         uint32_t sign_invoice_meth;
2830 } LDKKeysInterface_JCalls;
2831 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2832         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2833         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2834                 js_free(j_calls->get_node_secret_meth);
2835                 js_free(j_calls->get_destination_script_meth);
2836                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
2837                 js_free(j_calls->get_channel_signer_meth);
2838                 js_free(j_calls->get_secure_random_bytes_meth);
2839                 js_free(j_calls->read_chan_signer_meth);
2840                 js_free(j_calls->sign_invoice_meth);
2841                 FREE(j_calls);
2842         }
2843 }
2844 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2845         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2846         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2847         LDKSecretKey ret_ref;
2848         CHECK(*((uint32_t*)ret) == 32);
2849         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2850         return ret_ref;
2851 }
2852 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2853         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2854         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2855         LDKCVec_u8Z ret_ref;
2856         ret_ref.datalen = *((uint32_t*)ret);
2857         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2858         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2859         return ret_ref;
2860 }
2861 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
2862         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2863         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
2864         LDKShutdownScript ret_conv;
2865         ret_conv.inner = (void*)(ret & (~1));
2866         ret_conv.is_owned = (ret & 1) || (ret == 0);
2867         ret_conv = ShutdownScript_clone(&ret_conv);
2868         return ret_conv;
2869 }
2870 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2871         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2872         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2873         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2874         ret_conv = Sign_clone(&ret_conv);
2875         return ret_conv;
2876 }
2877 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2878         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2879         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2880         LDKThirtyTwoBytes ret_ref;
2881         CHECK(*((uint32_t*)ret) == 32);
2882         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2883         return ret_ref;
2884 }
2885 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2886         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2887         LDKu8slice reader_var = reader;
2888         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2889         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2890         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2891         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2892         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2893         return ret_conv;
2894 }
2895 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2896         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2897         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2898         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2899         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2900         CVec_u8Z_free(invoice_preimage_var);
2901         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2902         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2903         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2904         return ret_conv;
2905 }
2906 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
2907         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
2908         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2909 }
2910 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2911         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2912         atomic_init(&calls->refcnt, 1);
2913         //TODO: Assign calls->o from o
2914
2915         LDKKeysInterface ret = {
2916                 .this_arg = (void*) calls,
2917                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2918                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2919                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
2920                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2921                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2922                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2923                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2924                 .free = LDKKeysInterface_JCalls_free,
2925         };
2926         return ret;
2927 }
2928 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2929         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2930         *res_ptr = LDKKeysInterface_init(o);
2931         return (long)res_ptr;
2932 }
2933 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2934         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2935         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2936         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2937         return ret_arr;
2938 }
2939
2940 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2941         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2942         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2943         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2944         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2945         CVec_u8Z_free(ret_var);
2946         return ret_arr;
2947 }
2948
2949 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
2950         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2951         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
2952         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2953         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2954         uint64_t ret_ref = (uint64_t)ret_var.inner;
2955         if (ret_var.is_owned) {
2956                 ret_ref |= 1;
2957         }
2958         return ret_ref;
2959 }
2960
2961 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2962         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2963         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
2964         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2965         return (uint64_t)ret_ret;
2966 }
2967
2968 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2969         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2970         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2971         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2972         return ret_arr;
2973 }
2974
2975 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2976         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2977         LDKu8slice reader_ref;
2978         reader_ref.datalen = *((uint32_t*)reader);
2979         reader_ref.data = (int8_t*)(reader + 4);
2980         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2981         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2982         return (uint64_t)ret_conv;
2983 }
2984
2985 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2986         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2987         LDKCVec_u8Z invoice_preimage_ref;
2988         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2989         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2990         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2991         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2992         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2993         return (uint64_t)ret_conv;
2994 }
2995
2996 typedef struct LDKFeeEstimator_JCalls {
2997         atomic_size_t refcnt;
2998         uint32_t get_est_sat_per_1000_weight_meth;
2999 } LDKFeeEstimator_JCalls;
3000 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3001         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3002         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3003                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
3004                 FREE(j_calls);
3005         }
3006 }
3007 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3008         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3009         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
3010         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3011 }
3012 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
3013         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
3014         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3015 }
3016 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
3017         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3018         atomic_init(&calls->refcnt, 1);
3019         //TODO: Assign calls->o from o
3020
3021         LDKFeeEstimator ret = {
3022                 .this_arg = (void*) calls,
3023                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3024                 .free = LDKFeeEstimator_JCalls_free,
3025         };
3026         return ret;
3027 }
3028 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
3029         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3030         *res_ptr = LDKFeeEstimator_init(o);
3031         return (long)res_ptr;
3032 }
3033 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
3034         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
3035         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
3036         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3037         return ret_val;
3038 }
3039
3040 typedef struct LDKLogger_JCalls {
3041         atomic_size_t refcnt;
3042         uint32_t log_meth;
3043 } LDKLogger_JCalls;
3044 static void LDKLogger_JCalls_free(void* this_arg) {
3045         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3046         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3047                 js_free(j_calls->log_meth);
3048                 FREE(j_calls);
3049         }
3050 }
3051 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
3052         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3053         const char* record_str = record;
3054         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
3055         js_invoke_function_1(j_calls->log_meth, record_conv);
3056 }
3057 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3058         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3059         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3060 }
3061 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
3062         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3063         atomic_init(&calls->refcnt, 1);
3064         //TODO: Assign calls->o from o
3065
3066         LDKLogger ret = {
3067                 .this_arg = (void*) calls,
3068                 .log = log_LDKLogger_jcall,
3069                 .free = LDKLogger_JCalls_free,
3070         };
3071         return ret;
3072 }
3073 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
3074         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3075         *res_ptr = LDKLogger_init(o);
3076         return (long)res_ptr;
3077 }
3078 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
3079         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3080         LDKThirtyTwoBytes a_ref;
3081         CHECK(*((uint32_t*)a) == 32);
3082         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3083         ret->a = a_ref;
3084         LDKChannelManager b_conv;
3085         b_conv.inner = (void*)(b & (~1));
3086         b_conv.is_owned = (b & 1) || (b == 0);
3087         // Warning: we need a move here but no clone is available for LDKChannelManager
3088         ret->b = b_conv;
3089         return (uint64_t)ret;
3090 }
3091 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3092         return ThirtyTwoBytes_clone(&tuple->a);
3093 }
3094 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
3095         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3096         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3097         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
3098         return ret_arr;
3099 }
3100
3101 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3102         return &tuple->b;
3103 }
3104 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
3105         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3106         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
3107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3109         uint64_t ret_ref = (uint64_t)ret_var.inner & ~1;
3110         return ret_ref;
3111 }
3112
3113 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
3114         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3115 }
3116 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
3117         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3118         CHECK(val->result_ok);
3119         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3120         *res_conv = (*val->contents.result);
3121         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
3122         return ((uint64_t)res_conv) | 1;
3123 }
3124 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
3125         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3126         CHECK(!val->result_ok);
3127         LDKDecodeError err_var = (*val->contents.err);
3128         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3129         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3130         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3131         return err_ref;
3132 }
3133 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
3134         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
3135 }
3136 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
3137         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3138         CHECK(val->result_ok);
3139         LDKChannelConfig res_var = (*val->contents.result);
3140         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3141         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3142         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3143         return res_ref;
3144 }
3145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
3146         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3147         CHECK(!val->result_ok);
3148         LDKDecodeError err_var = (*val->contents.err);
3149         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3150         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3151         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3152         return err_ref;
3153 }
3154 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
3155         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
3156 }
3157 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3158         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3159         CHECK(val->result_ok);
3160         LDKOutPoint res_var = (*val->contents.result);
3161         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3162         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3163         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3164         return res_ref;
3165 }
3166 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3167         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3168         CHECK(!val->result_ok);
3169         LDKDecodeError err_var = (*val->contents.err);
3170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3172         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3173         return err_ref;
3174 }
3175 typedef struct LDKType_JCalls {
3176         atomic_size_t refcnt;
3177         uint32_t type_id_meth;
3178         uint32_t debug_str_meth;
3179         uint32_t write_meth;
3180 } LDKType_JCalls;
3181 static void LDKType_JCalls_free(void* this_arg) {
3182         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3183         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3184                 js_free(j_calls->type_id_meth);
3185                 js_free(j_calls->debug_str_meth);
3186                 js_free(j_calls->write_meth);
3187                 FREE(j_calls);
3188         }
3189 }
3190 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3191         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3192         return js_invoke_function_0(j_calls->type_id_meth);
3193 }
3194 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3195         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3196         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3197         LDKStr ret_conv = str_ref_to_owned_c(ret);
3198         return ret_conv;
3199 }
3200 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3201         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3202         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3203         LDKCVec_u8Z ret_ref;
3204         ret_ref.datalen = *((uint32_t*)ret);
3205         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3206         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3207         return ret_ref;
3208 }
3209 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3210         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3211         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3212 }
3213 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3214         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3215         atomic_init(&calls->refcnt, 1);
3216         //TODO: Assign calls->o from o
3217
3218         LDKType ret = {
3219                 .this_arg = (void*) calls,
3220                 .type_id = type_id_LDKType_jcall,
3221                 .debug_str = debug_str_LDKType_jcall,
3222                 .write = write_LDKType_jcall,
3223                 .cloned = LDKType_JCalls_cloned,
3224                 .free = LDKType_JCalls_free,
3225         };
3226         return ret;
3227 }
3228 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3229         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3230         *res_ptr = LDKType_init(o);
3231         return (long)res_ptr;
3232 }
3233 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3234         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3235         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3236         return ret_val;
3237 }
3238
3239 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3240         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3241         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3242         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3243         Str_free(ret_str);
3244         return ret_conv;
3245 }
3246
3247 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3248         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3249         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3250         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3251         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3252         CVec_u8Z_free(ret_var);
3253         return ret_arr;
3254 }
3255
3256 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3257         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3258         switch(obj->tag) {
3259                 case LDKCOption_TypeZ_Some: {
3260                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
3261                         *some_ret = Type_clone(&obj->some);
3262                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3263                 }
3264                 case LDKCOption_TypeZ_None: {
3265                         return 0 /* LDKCOption_TypeZ - None */;
3266                 }
3267                 default: abort();
3268         }
3269 }
3270 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) {
3271         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
3272 }
3273 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3274         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3275         CHECK(val->result_ok);
3276         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3277         return res_ref;
3278 }
3279 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3280         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3281         CHECK(!val->result_ok);
3282         LDKDecodeError err_var = (*val->contents.err);
3283         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3284         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3285         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3286         return err_ref;
3287 }
3288 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
3289         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
3290 }
3291 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3292         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3293         CHECK(val->result_ok);
3294         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3295         return res_conv;
3296 }
3297 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3298         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3299         CHECK(!val->result_ok);
3300         return *val->contents.err;
3301 }
3302 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
3303         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
3304 }
3305 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3306         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3307         CHECK(val->result_ok);
3308         LDKInvoice res_var = (*val->contents.result);
3309         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3310         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3311         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3312         return res_ref;
3313 }
3314 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3315         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3316         CHECK(!val->result_ok);
3317         return *val->contents.err;
3318 }
3319 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
3320         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
3321 }
3322 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3323         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3324         CHECK(val->result_ok);
3325         LDKSignedRawInvoice res_var = (*val->contents.result);
3326         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3327         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3328         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3329         return res_ref;
3330 }
3331 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3332         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3333         CHECK(!val->result_ok);
3334         return *val->contents.err;
3335 }
3336 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
3337         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
3338         LDKRawInvoice a_conv;
3339         a_conv.inner = (void*)(a & (~1));
3340         a_conv.is_owned = (a & 1) || (a == 0);
3341         a_conv = RawInvoice_clone(&a_conv);
3342         ret->a = a_conv;
3343         LDKThirtyTwoBytes b_ref;
3344         CHECK(*((uint32_t*)b) == 32);
3345         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
3346         ret->b = b_ref;
3347         LDKInvoiceSignature c_conv;
3348         c_conv.inner = (void*)(c & (~1));
3349         c_conv.is_owned = (c & 1) || (c == 0);
3350         c_conv = InvoiceSignature_clone(&c_conv);
3351         ret->c = c_conv;
3352         return (uint64_t)ret;
3353 }
3354 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3355         return RawInvoice_clone(&tuple->a);
3356 }
3357 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
3358         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3359         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
3360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3362         uint64_t ret_ref = (uint64_t)ret_var.inner;
3363         if (ret_var.is_owned) {
3364                 ret_ref |= 1;
3365         }
3366         return ret_ref;
3367 }
3368
3369 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3370         return ThirtyTwoBytes_clone(&tuple->b);
3371 }
3372 int8_tArray  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
3373         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3374         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3375         memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
3376         return ret_arr;
3377 }
3378
3379 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3380         return InvoiceSignature_clone(&tuple->c);
3381 }
3382 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
3383         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3384         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
3385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3387         uint64_t ret_ref = (uint64_t)ret_var.inner;
3388         if (ret_var.is_owned) {
3389                 ret_ref |= 1;
3390         }
3391         return ret_ref;
3392 }
3393
3394 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
3395         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
3396 }
3397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3398         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3399         CHECK(val->result_ok);
3400         LDKPayeePubKey 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_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3407         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3408         CHECK(!val->result_ok);
3409         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3410         return err_conv;
3411 }
3412 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
3413         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
3414         ret->datalen = *((uint32_t*)elems);
3415         if (ret->datalen == 0) {
3416                 ret->data = NULL;
3417         } else {
3418                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
3419                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3420                 for (size_t i = 0; i < ret->datalen; i++) {
3421                         uint32_t arr_elem = java_elems[i];
3422                         LDKPrivateRoute arr_elem_conv;
3423                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3424                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3425                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
3426                         ret->data[i] = arr_elem_conv;
3427                 }
3428         }
3429         return (uint64_t)ret;
3430 }
3431 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3432         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3433         for (size_t i = 0; i < ret.datalen; i++) {
3434                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3435         }
3436         return ret;
3437 }
3438 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
3439         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
3440 }
3441 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3442         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3443         CHECK(val->result_ok);
3444         LDKPositiveTimestamp res_var = (*val->contents.result);
3445         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3446         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3447         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3448         return res_ref;
3449 }
3450 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3451         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3452         CHECK(!val->result_ok);
3453         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3454         return err_conv;
3455 }
3456 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
3457         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
3458 }
3459 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3460         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3461         CHECK(val->result_ok);
3462         return *val->contents.result;
3463 }
3464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3465         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3466         CHECK(!val->result_ok);
3467         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3468         return err_conv;
3469 }
3470 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3471         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3472 }
3473 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3474         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3475         CHECK(val->result_ok);
3476         LDKInvoice res_var = (*val->contents.result);
3477         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3478         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3479         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3480         return res_ref;
3481 }
3482 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3483         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3484         CHECK(!val->result_ok);
3485         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3486         return err_conv;
3487 }
3488 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3489         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3490 }
3491 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3492         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3493         CHECK(val->result_ok);
3494         LDKDescription res_var = (*val->contents.result);
3495         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3496         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3497         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3498         return res_ref;
3499 }
3500 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3501         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3502         CHECK(!val->result_ok);
3503         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3504         return err_conv;
3505 }
3506 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3507         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3508 }
3509 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3510         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3511         CHECK(val->result_ok);
3512         LDKExpiryTime res_var = (*val->contents.result);
3513         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3514         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3515         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3516         return res_ref;
3517 }
3518 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3519         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3520         CHECK(!val->result_ok);
3521         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3522         return err_conv;
3523 }
3524 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3525         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3526 }
3527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3528         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3529         CHECK(val->result_ok);
3530         LDKPrivateRoute res_var = (*val->contents.result);
3531         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3532         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3533         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3534         return res_ref;
3535 }
3536 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3537         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3538         CHECK(!val->result_ok);
3539         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3540         return err_conv;
3541 }
3542 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3543         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3544 }
3545 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3546         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3547         CHECK(val->result_ok);
3548         LDKStr res_str = (*val->contents.result);
3549         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3550         return res_conv;
3551 }
3552 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3553         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3554         CHECK(!val->result_ok);
3555         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3556         return err_conv;
3557 }
3558 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3559         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3560 }
3561 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3562         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3563         CHECK(val->result_ok);
3564         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3565         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3566         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3567         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3568         return res_ref;
3569 }
3570 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3571         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3572         CHECK(!val->result_ok);
3573         LDKDecodeError err_var = (*val->contents.err);
3574         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3575         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3576         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3577         return err_ref;
3578 }
3579 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3580         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3581 }
3582 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3583         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3584         CHECK(val->result_ok);
3585         LDKHTLCUpdate res_var = (*val->contents.result);
3586         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3587         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3588         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3589         return res_ref;
3590 }
3591 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3592         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3593         CHECK(!val->result_ok);
3594         LDKDecodeError err_var = (*val->contents.err);
3595         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3596         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3597         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3598         return err_ref;
3599 }
3600 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3601         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3602 }
3603 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3604         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3605         CHECK(val->result_ok);
3606         return *val->contents.result;
3607 }
3608 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3609         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3610         CHECK(!val->result_ok);
3611         LDKMonitorUpdateError err_var = (*val->contents.err);
3612         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3613         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3614         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3615         return err_ref;
3616 }
3617 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3618         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3619         LDKOutPoint a_conv;
3620         a_conv.inner = (void*)(a & (~1));
3621         a_conv.is_owned = (a & 1) || (a == 0);
3622         a_conv = OutPoint_clone(&a_conv);
3623         ret->a = a_conv;
3624         LDKCVec_u8Z b_ref;
3625         b_ref.datalen = *((uint32_t*)b);
3626         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3627         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3628         ret->b = b_ref;
3629         return (uint64_t)ret;
3630 }
3631 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3632         return OutPoint_clone(&tuple->a);
3633 }
3634 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
3635         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3636         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
3637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3639         uint64_t ret_ref = (uint64_t)ret_var.inner;
3640         if (ret_var.is_owned) {
3641                 ret_ref |= 1;
3642         }
3643         return ret_ref;
3644 }
3645
3646 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3647         return CVec_u8Z_clone(&tuple->b);
3648 }
3649 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
3650         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3651         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
3652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3654         CVec_u8Z_free(ret_var);
3655         return ret_arr;
3656 }
3657
3658 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3659         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3660         ret->a = a;
3661         LDKCVec_u8Z b_ref;
3662         b_ref.datalen = *((uint32_t*)b);
3663         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3664         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3665         ret->b = b_ref;
3666         return (uint64_t)ret;
3667 }
3668 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3669         return tuple->a;
3670 }
3671 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
3672         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3673         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
3674         return ret_val;
3675 }
3676
3677 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3678         return CVec_u8Z_clone(&tuple->b);
3679 }
3680 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
3681         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3682         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
3683         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3684         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3685         CVec_u8Z_free(ret_var);
3686         return ret_arr;
3687 }
3688
3689 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3690         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3691         ret->datalen = *((uint32_t*)elems);
3692         if (ret->datalen == 0) {
3693                 ret->data = NULL;
3694         } else {
3695                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3696                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3697                 for (size_t i = 0; i < ret->datalen; i++) {
3698                         uint32_t arr_elem = java_elems[i];
3699                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3700                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3701                         ret->data[i] = arr_elem_conv;
3702                 }
3703         }
3704         return (uint64_t)ret;
3705 }
3706 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3707         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3708         for (size_t i = 0; i < ret.datalen; i++) {
3709                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3710         }
3711         return ret;
3712 }
3713 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3714         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3715         LDKThirtyTwoBytes a_ref;
3716         CHECK(*((uint32_t*)a) == 32);
3717         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3718         ret->a = a_ref;
3719         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3720         b_constr.datalen = *((uint32_t*)b);
3721         if (b_constr.datalen > 0)
3722                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3723         else
3724                 b_constr.data = NULL;
3725         uint32_t* b_vals = (uint32_t*)(b + 4);
3726         for (size_t v = 0; v < b_constr.datalen; v++) {
3727                 uint32_t b_conv_21 = b_vals[v];
3728                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
3729                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
3730                 b_constr.data[v] = b_conv_21_conv;
3731         }
3732         ret->b = b_constr;
3733         return (uint64_t)ret;
3734 }
3735 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3736         return ThirtyTwoBytes_clone(&tuple->a);
3737 }
3738 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
3739         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3740         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3741         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
3742         return ret_arr;
3743 }
3744
3745 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3746         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
3747 }
3748 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
3749         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3750         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
3751         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3752         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3753         for (size_t v = 0; v < ret_var.datalen; v++) {
3754                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3755                 *ret_conv_21_conv = ret_var.data[v];
3756                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
3757         }
3758         FREE(ret_var.data);
3759         return ret_arr;
3760 }
3761
3762 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3763         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3764         ret->datalen = *((uint32_t*)elems);
3765         if (ret->datalen == 0) {
3766                 ret->data = NULL;
3767         } else {
3768                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3769                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3770                 for (size_t i = 0; i < ret->datalen; i++) {
3771                         uint32_t arr_elem = java_elems[i];
3772                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3773                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3774                         ret->data[i] = arr_elem_conv;
3775                 }
3776         }
3777         return (uint64_t)ret;
3778 }
3779 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3780         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 };
3781         for (size_t i = 0; i < ret.datalen; i++) {
3782                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3783         }
3784         return ret;
3785 }
3786 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
3787         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
3788         switch(obj->tag) {
3789                 case LDKPaymentPurpose_InvoicePayment: {
3790                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3791                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
3792                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3793                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
3794                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
3795                 }
3796                 case LDKPaymentPurpose_SpontaneousPayment: {
3797                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3798                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
3799                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
3800                 }
3801                 default: abort();
3802         }
3803 }
3804 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
3805         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
3806         switch(obj->tag) {
3807                 case LDKClosureReason_CounterpartyForceClosed: {
3808                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
3809                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
3810                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
3811                 }
3812                 case LDKClosureReason_HolderForceClosed: {
3813                         return 0 /* LDKClosureReason - HolderForceClosed */;
3814                 }
3815                 case LDKClosureReason_CooperativeClosure: {
3816                         return 0 /* LDKClosureReason - CooperativeClosure */;
3817                 }
3818                 case LDKClosureReason_CommitmentTxConfirmed: {
3819                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
3820                 }
3821                 case LDKClosureReason_ProcessingError: {
3822                         LDKStr err_str = obj->processing_error.err;
3823                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3824                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
3825                 }
3826                 case LDKClosureReason_DisconnectedPeer: {
3827                         return 0 /* LDKClosureReason - DisconnectedPeer */;
3828                 }
3829                 case LDKClosureReason_OutdatedChannelManager: {
3830                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
3831                 }
3832                 default: abort();
3833         }
3834 }
3835 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3836         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3837         switch(obj->tag) {
3838                 case LDKEvent_FundingGenerationReady: {
3839                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3840                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3841                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3842                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3843                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3844                         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;
3845                 }
3846                 case LDKEvent_PaymentReceived: {
3847                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3848                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3849                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
3850                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
3851                 }
3852                 case LDKEvent_PaymentSent: {
3853                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3854                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3855                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3856                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
3857                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr; (void) payment_hash_arr;
3858                 }
3859                 case LDKEvent_PaymentPathFailed: {
3860                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3861                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
3862                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
3863                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3864                         uint32_tArray path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3865                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
3866                         for (size_t k = 0; k < path_var.datalen; k++) {
3867                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3868                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3869                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3870                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
3871                                 path_arr_ptr[k] = path_conv_10_ref;
3872                         }
3873                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
3874                         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; (void) short_channel_id_ref;
3875                 }
3876                 case LDKEvent_PendingHTLCsForwardable: {
3877                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3878                 }
3879                 case LDKEvent_SpendableOutputs: {
3880                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3881                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3882                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3883                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3884                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3885                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3886                         }
3887                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3888                 }
3889                 case LDKEvent_PaymentForwarded: {
3890                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
3891                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
3892                 }
3893                 case LDKEvent_ChannelClosed: {
3894                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3895                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
3896                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
3897                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
3898                 }
3899                 case LDKEvent_DiscardFunding: {
3900                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3901                         memcpy((uint8_t*)(channel_id_arr + 4), obj->discard_funding.channel_id.data, 32);
3902                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3903                         int8_tArray transaction_arr = init_arr(transaction_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3904                         memcpy((uint8_t*)(transaction_arr + 4), transaction_var.data, transaction_var.datalen);
3905                         return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
3906                 }
3907                 default: abort();
3908         }
3909 }
3910 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3911         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3912         ret->datalen = *((uint32_t*)elems);
3913         if (ret->datalen == 0) {
3914                 ret->data = NULL;
3915         } else {
3916                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3917                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3918                 for (size_t i = 0; i < ret->datalen; i++) {
3919                         uint32_t arr_elem = java_elems[i];
3920                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3921                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3922                         ret->data[i] = arr_elem_conv;
3923                 }
3924         }
3925         return (uint64_t)ret;
3926 }
3927 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3928         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3929         for (size_t i = 0; i < ret.datalen; i++) {
3930                 ret.data[i] = Event_clone(&orig->data[i]);
3931         }
3932         return ret;
3933 }
3934 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3935         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3936         ret->a = a;
3937         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3938         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3939         ret->b = b_conv;
3940         return (uint64_t)ret;
3941 }
3942 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3943         return tuple->a;
3944 }
3945 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
3946         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3947         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
3948         return ret_val;
3949 }
3950
3951 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3952         return TxOut_clone(&tuple->b);
3953 }
3954 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
3955         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3956         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3957         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
3958         return (uint64_t)ret_ref;
3959 }
3960
3961 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3962         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3963         ret->datalen = *((uint32_t*)elems);
3964         if (ret->datalen == 0) {
3965                 ret->data = NULL;
3966         } else {
3967                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3968                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3969                 for (size_t i = 0; i < ret->datalen; i++) {
3970                         uint32_t arr_elem = java_elems[i];
3971                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3972                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3973                         ret->data[i] = arr_elem_conv;
3974                 }
3975         }
3976         return (uint64_t)ret;
3977 }
3978 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3979         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3980         for (size_t i = 0; i < ret.datalen; i++) {
3981                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3982         }
3983         return ret;
3984 }
3985 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3986         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3987         LDKThirtyTwoBytes a_ref;
3988         CHECK(*((uint32_t*)a) == 32);
3989         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3990         ret->a = a_ref;
3991         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3992         b_constr.datalen = *((uint32_t*)b);
3993         if (b_constr.datalen > 0)
3994                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3995         else
3996                 b_constr.data = NULL;
3997         uint32_t* b_vals = (uint32_t*)(b + 4);
3998         for (size_t u = 0; u < b_constr.datalen; u++) {
3999                 uint32_t b_conv_20 = b_vals[u];
4000                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
4001                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
4002                 b_constr.data[u] = b_conv_20_conv;
4003         }
4004         ret->b = b_constr;
4005         return (uint64_t)ret;
4006 }
4007 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4008         return ThirtyTwoBytes_clone(&tuple->a);
4009 }
4010 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
4011         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4012         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4013         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
4014         return ret_arr;
4015 }
4016
4017 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4018         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
4019 }
4020 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
4021         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4022         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
4023         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4024         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4025         for (size_t u = 0; u < ret_var.datalen; u++) {
4026                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4027                 *ret_conv_20_conv = ret_var.data[u];
4028                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
4029         }
4030         FREE(ret_var.data);
4031         return ret_arr;
4032 }
4033
4034 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
4035         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4036         ret->datalen = *((uint32_t*)elems);
4037         if (ret->datalen == 0) {
4038                 ret->data = NULL;
4039         } else {
4040                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4041                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4042                 for (size_t i = 0; i < ret->datalen; i++) {
4043                         uint32_t arr_elem = java_elems[i];
4044                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4045                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4046                         ret->data[i] = arr_elem_conv;
4047                 }
4048         }
4049         return (uint64_t)ret;
4050 }
4051 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4052         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 };
4053         for (size_t i = 0; i < ret.datalen; i++) {
4054                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4055         }
4056         return ret;
4057 }
4058 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
4059         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
4060         switch(obj->tag) {
4061                 case LDKBalance_ClaimableOnChannelClose: {
4062                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
4063                 }
4064                 case LDKBalance_ClaimableAwaitingConfirmations: {
4065                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
4066                 }
4067                 case LDKBalance_ContentiousClaimable: {
4068                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
4069                 }
4070                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
4071                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
4072                 }
4073                 default: abort();
4074         }
4075 }
4076 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) {
4077         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
4078         ret->datalen = *((uint32_t*)elems);
4079         if (ret->datalen == 0) {
4080                 ret->data = NULL;
4081         } else {
4082                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
4083                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4084                 for (size_t i = 0; i < ret->datalen; i++) {
4085                         uint32_t arr_elem = java_elems[i];
4086                         LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1);
4087                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
4088                         ret->data[i] = arr_elem_conv;
4089                 }
4090         }
4091         return (uint64_t)ret;
4092 }
4093 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
4094         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
4095         for (size_t i = 0; i < ret.datalen; i++) {
4096                 ret.data[i] = Balance_clone(&orig->data[i]);
4097         }
4098         return ret;
4099 }
4100 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
4101         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4102 }
4103 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
4104         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4105         CHECK(val->result_ok);
4106         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4107         *res_conv = (*val->contents.result);
4108         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
4109         return ((uint64_t)res_conv);
4110 }
4111 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
4112         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4113         CHECK(!val->result_ok);
4114         LDKDecodeError err_var = (*val->contents.err);
4115         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4116         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4117         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4118         return err_ref;
4119 }
4120 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
4121         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4122 }
4123 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
4124         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4125         CHECK(val->result_ok);
4126         return *val->contents.result;
4127 }
4128 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
4129         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4130         CHECK(!val->result_ok);
4131         LDKLightningError err_var = (*val->contents.err);
4132         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4133         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4134         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4135         return err_ref;
4136 }
4137 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
4138         LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
4139         LDKPublicKey a_ref;
4140         CHECK(*((uint32_t*)a) == 33);
4141         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
4142         ret->a = a_ref;
4143         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
4144         b_conv = Type_clone(&b_conv);
4145         ret->b = b_conv;
4146         return (uint64_t)ret;
4147 }
4148 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4149         return tuple->a;
4150 }
4151 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
4152         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4153         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4154         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
4155         return ret_arr;
4156 }
4157
4158 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4159         return Type_clone(&tuple->b);
4160 }
4161 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
4162         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4163         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
4164         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
4165         return (uint64_t)ret_ret;
4166 }
4167
4168 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) {
4169         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
4170         ret->datalen = *((uint32_t*)elems);
4171         if (ret->datalen == 0) {
4172                 ret->data = NULL;
4173         } else {
4174                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ 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                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1);
4179                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
4180                         ret->data[i] = arr_elem_conv;
4181                 }
4182         }
4183         return (uint64_t)ret;
4184 }
4185 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
4186         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
4187         for (size_t i = 0; i < ret.datalen; i++) {
4188                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
4189         }
4190         return ret;
4191 }
4192 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
4193         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4194 }
4195 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
4196         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4197         CHECK(val->result_ok);
4198         return *val->contents.result;
4199 }
4200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
4201         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4202         CHECK(!val->result_ok);
4203         LDKLightningError err_var = (*val->contents.err);
4204         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4205         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4206         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4207         return err_ref;
4208 }
4209 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
4210         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4211         LDKChannelAnnouncement a_conv;
4212         a_conv.inner = (void*)(a & (~1));
4213         a_conv.is_owned = (a & 1) || (a == 0);
4214         a_conv = ChannelAnnouncement_clone(&a_conv);
4215         ret->a = a_conv;
4216         LDKChannelUpdate b_conv;
4217         b_conv.inner = (void*)(b & (~1));
4218         b_conv.is_owned = (b & 1) || (b == 0);
4219         b_conv = ChannelUpdate_clone(&b_conv);
4220         ret->b = b_conv;
4221         LDKChannelUpdate c_conv;
4222         c_conv.inner = (void*)(c & (~1));
4223         c_conv.is_owned = (c & 1) || (c == 0);
4224         c_conv = ChannelUpdate_clone(&c_conv);
4225         ret->c = c_conv;
4226         return (uint64_t)ret;
4227 }
4228 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4229         return ChannelAnnouncement_clone(&tuple->a);
4230 }
4231 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
4232         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4233         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
4234         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4235         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4236         uint64_t ret_ref = (uint64_t)ret_var.inner;
4237         if (ret_var.is_owned) {
4238                 ret_ref |= 1;
4239         }
4240         return ret_ref;
4241 }
4242
4243 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4244         return ChannelUpdate_clone(&tuple->b);
4245 }
4246 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
4247         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4248         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
4249         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4250         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4251         uint64_t ret_ref = (uint64_t)ret_var.inner;
4252         if (ret_var.is_owned) {
4253                 ret_ref |= 1;
4254         }
4255         return ret_ref;
4256 }
4257
4258 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4259         return ChannelUpdate_clone(&tuple->c);
4260 }
4261 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
4262         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4263         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
4264         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4265         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4266         uint64_t ret_ref = (uint64_t)ret_var.inner;
4267         if (ret_var.is_owned) {
4268                 ret_ref |= 1;
4269         }
4270         return ret_ref;
4271 }
4272
4273 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
4274         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4275         ret->datalen = *((uint32_t*)elems);
4276         if (ret->datalen == 0) {
4277                 ret->data = NULL;
4278         } else {
4279                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4280                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4281                 for (size_t i = 0; i < ret->datalen; i++) {
4282                         uint32_t arr_elem = java_elems[i];
4283                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4284                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4285                         ret->data[i] = arr_elem_conv;
4286                 }
4287         }
4288         return (uint64_t)ret;
4289 }
4290 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4291         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4292         for (size_t i = 0; i < ret.datalen; i++) {
4293                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4294         }
4295         return ret;
4296 }
4297 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
4298         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4299         ret->datalen = *((uint32_t*)elems);
4300         if (ret->datalen == 0) {
4301                 ret->data = NULL;
4302         } else {
4303                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4304                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4305                 for (size_t i = 0; i < ret->datalen; i++) {
4306                         uint32_t arr_elem = java_elems[i];
4307                         LDKNodeAnnouncement arr_elem_conv;
4308                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4309                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4310                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4311                         ret->data[i] = arr_elem_conv;
4312                 }
4313         }
4314         return (uint64_t)ret;
4315 }
4316 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4317         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4318         for (size_t i = 0; i < ret.datalen; i++) {
4319                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4320         }
4321         return ret;
4322 }
4323 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
4324         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4325 }
4326 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4327         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4328         CHECK(val->result_ok);
4329         LDKCVec_u8Z res_var = (*val->contents.result);
4330         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4331         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4332         return res_arr;
4333 }
4334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4335         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4336         CHECK(!val->result_ok);
4337         LDKPeerHandleError err_var = (*val->contents.err);
4338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4340         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4341         return err_ref;
4342 }
4343 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
4344         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4345 }
4346 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4347         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4348         CHECK(val->result_ok);
4349         return *val->contents.result;
4350 }
4351 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4352         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4353         CHECK(!val->result_ok);
4354         LDKPeerHandleError 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_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
4361         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4362 }
4363 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4364         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4365         CHECK(val->result_ok);
4366         return *val->contents.result;
4367 }
4368 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4369         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4370         CHECK(!val->result_ok);
4371         LDKPeerHandleError err_var = (*val->contents.err);
4372         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4373         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4374         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4375         return err_ref;
4376 }
4377 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_result_ok(uint32_t arg) {
4378         return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
4379 }
4380 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_ok(uint32_t arg) {
4381         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4382         CHECK(val->result_ok);
4383         LDKNodeId res_var = (*val->contents.result);
4384         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4387         return res_ref;
4388 }
4389 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
4390         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4391         CHECK(!val->result_ok);
4392         LDKDecodeError err_var = (*val->contents.err);
4393         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4394         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4395         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4396         return err_ref;
4397 }
4398 typedef struct LDKAccess_JCalls {
4399         atomic_size_t refcnt;
4400         uint32_t get_utxo_meth;
4401 } LDKAccess_JCalls;
4402 static void LDKAccess_JCalls_free(void* this_arg) {
4403         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4404         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4405                 js_free(j_calls->get_utxo_meth);
4406                 FREE(j_calls);
4407         }
4408 }
4409 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4410         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4411         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4412         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4413         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4414         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4415         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4416         return ret_conv;
4417 }
4418 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4419         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4420         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4421 }
4422 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4423         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4424         atomic_init(&calls->refcnt, 1);
4425         //TODO: Assign calls->o from o
4426
4427         LDKAccess ret = {
4428                 .this_arg = (void*) calls,
4429                 .get_utxo = get_utxo_LDKAccess_jcall,
4430                 .free = LDKAccess_JCalls_free,
4431         };
4432         return ret;
4433 }
4434 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4435         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4436         *res_ptr = LDKAccess_init(o);
4437         return (long)res_ptr;
4438 }
4439 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4440         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4441         unsigned char genesis_hash_arr[32];
4442         CHECK(*((uint32_t*)genesis_hash) == 32);
4443         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4444         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4445         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4446         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4447         return (uint64_t)ret_conv;
4448 }
4449
4450 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4451         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4452         switch(obj->tag) {
4453                 case LDKCOption_AccessZ_Some: {
4454                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
4455                         *some_ret = obj->some;
4456                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4457                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4458                 }
4459                 case LDKCOption_AccessZ_None: {
4460                         return 0 /* LDKCOption_AccessZ - None */;
4461                 }
4462                 default: abort();
4463         }
4464 }
4465 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4466         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4467 }
4468 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4469         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4470         CHECK(val->result_ok);
4471         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4472         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4473         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4474         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4475         return res_ref;
4476 }
4477 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4478         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4479         CHECK(!val->result_ok);
4480         LDKDecodeError err_var = (*val->contents.err);
4481         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4482         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4483         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4484         return err_ref;
4485 }
4486 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4487         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4488 }
4489 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4490         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4491         CHECK(val->result_ok);
4492         LDKChannelInfo res_var = (*val->contents.result);
4493         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4494         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4495         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4496         return res_ref;
4497 }
4498 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4499         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4500         CHECK(!val->result_ok);
4501         LDKDecodeError err_var = (*val->contents.err);
4502         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4503         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4504         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4505         return err_ref;
4506 }
4507 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
4508         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4509 }
4510 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4511         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4512         CHECK(val->result_ok);
4513         LDKRoutingFees res_var = (*val->contents.result);
4514         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4515         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4516         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4517         return res_ref;
4518 }
4519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4520         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4521         CHECK(!val->result_ok);
4522         LDKDecodeError err_var = (*val->contents.err);
4523         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4524         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4525         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4526         return err_ref;
4527 }
4528 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
4529         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4530 }
4531 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4532         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4533         CHECK(val->result_ok);
4534         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4535         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4536         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4537         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4538         return res_ref;
4539 }
4540 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4541         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4542         CHECK(!val->result_ok);
4543         LDKDecodeError err_var = (*val->contents.err);
4544         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4545         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4546         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4547         return err_ref;
4548 }
4549 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
4550         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
4551         ret->datalen = *((uint32_t*)elems);
4552         if (ret->datalen == 0) {
4553                 ret->data = NULL;
4554         } else {
4555                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
4556                 int64_t *java_elems = (int64_t*)(elems + 4);
4557                 for (size_t i = 0; i < ret->datalen; i++) {
4558                         ret->data[i] = java_elems[i];
4559                 }
4560         }
4561         return (uint64_t)ret;
4562 }
4563 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4564         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4565         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4566         return ret;
4567 }
4568 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
4569         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
4570 }
4571 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4572         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4573         CHECK(val->result_ok);
4574         LDKNodeInfo res_var = (*val->contents.result);
4575         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4576         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4577         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4578         return res_ref;
4579 }
4580 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4581         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4582         CHECK(!val->result_ok);
4583         LDKDecodeError err_var = (*val->contents.err);
4584         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4585         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4586         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4587         return err_ref;
4588 }
4589 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
4590         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
4591 }
4592 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4593         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4594         CHECK(val->result_ok);
4595         LDKNetworkGraph res_var = (*val->contents.result);
4596         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4597         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4598         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4599         return res_ref;
4600 }
4601 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4602         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4603         CHECK(!val->result_ok);
4604         LDKDecodeError err_var = (*val->contents.err);
4605         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4606         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4607         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4608         return err_ref;
4609 }
4610 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
4611         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4612         switch(obj->tag) {
4613                 case LDKCOption_CVec_NetAddressZZ_Some: {
4614                         LDKCVec_NetAddressZ some_var = obj->some;
4615                         uint32_tArray some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4616                         uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
4617                         for (size_t m = 0; m < some_var.datalen; m++) {
4618                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
4619                                 some_arr_ptr[m] = some_conv_12_ref;
4620                         }
4621                         return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
4622                 }
4623                 case LDKCOption_CVec_NetAddressZZ_None: {
4624                         return 0 /* LDKCOption_CVec_NetAddressZZ - None */;
4625                 }
4626                 default: abort();
4627         }
4628 }
4629 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
4630         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
4631 }
4632 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
4633         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4634         CHECK(val->result_ok);
4635         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4636         return res_ref;
4637 }
4638 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
4639         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4640         CHECK(!val->result_ok);
4641         return *val->contents.err;
4642 }
4643 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
4644         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
4645 }
4646 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
4647         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4648         CHECK(val->result_ok);
4649         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
4650         *res_conv = (*val->contents.result);
4651         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
4652         return (uint64_t)res_conv;
4653 }
4654 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
4655         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4656         CHECK(!val->result_ok);
4657         LDKDecodeError err_var = (*val->contents.err);
4658         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4659         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4660         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4661         return err_ref;
4662 }
4663 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
4664         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
4665 }
4666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4667         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4668         CHECK(val->result_ok);
4669         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4670         return res_ref;
4671 }
4672 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4673         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4674         CHECK(!val->result_ok);
4675         LDKDecodeError err_var = (*val->contents.err);
4676         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4677         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4678         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4679         return err_ref;
4680 }
4681 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
4682         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
4683         ret->datalen = *((uint32_t*)elems);
4684         if (ret->datalen == 0) {
4685                 ret->data = NULL;
4686         } else {
4687                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
4688                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4689                 for (size_t i = 0; i < ret->datalen; i++) {
4690                         uint32_t arr_elem = java_elems[i];
4691                         LDKUpdateAddHTLC arr_elem_conv;
4692                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4693                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4694                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
4695                         ret->data[i] = arr_elem_conv;
4696                 }
4697         }
4698         return (uint64_t)ret;
4699 }
4700 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4701         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4702         for (size_t i = 0; i < ret.datalen; i++) {
4703                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4704         }
4705         return ret;
4706 }
4707 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
4708         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
4709         ret->datalen = *((uint32_t*)elems);
4710         if (ret->datalen == 0) {
4711                 ret->data = NULL;
4712         } else {
4713                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
4714                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4715                 for (size_t i = 0; i < ret->datalen; i++) {
4716                         uint32_t arr_elem = java_elems[i];
4717                         LDKUpdateFulfillHTLC arr_elem_conv;
4718                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4719                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4720                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4721                         ret->data[i] = arr_elem_conv;
4722                 }
4723         }
4724         return (uint64_t)ret;
4725 }
4726 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4727         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4728         for (size_t i = 0; i < ret.datalen; i++) {
4729                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4730         }
4731         return ret;
4732 }
4733 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
4734         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4735         ret->datalen = *((uint32_t*)elems);
4736         if (ret->datalen == 0) {
4737                 ret->data = NULL;
4738         } else {
4739                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
4740                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4741                 for (size_t i = 0; i < ret->datalen; i++) {
4742                         uint32_t arr_elem = java_elems[i];
4743                         LDKUpdateFailHTLC arr_elem_conv;
4744                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4745                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4746                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
4747                         ret->data[i] = arr_elem_conv;
4748                 }
4749         }
4750         return (uint64_t)ret;
4751 }
4752 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4753         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4754         for (size_t i = 0; i < ret.datalen; i++) {
4755                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4756         }
4757         return ret;
4758 }
4759 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
4760         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
4761         ret->datalen = *((uint32_t*)elems);
4762         if (ret->datalen == 0) {
4763                 ret->data = NULL;
4764         } else {
4765                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
4766                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4767                 for (size_t i = 0; i < ret->datalen; i++) {
4768                         uint32_t arr_elem = java_elems[i];
4769                         LDKUpdateFailMalformedHTLC arr_elem_conv;
4770                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4771                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4772                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
4773                         ret->data[i] = arr_elem_conv;
4774                 }
4775         }
4776         return (uint64_t)ret;
4777 }
4778 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4779         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4780         for (size_t i = 0; i < ret.datalen; i++) {
4781                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4782         }
4783         return ret;
4784 }
4785 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
4786         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
4787 }
4788 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4789         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4790         CHECK(val->result_ok);
4791         LDKAcceptChannel res_var = (*val->contents.result);
4792         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4793         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4794         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4795         return res_ref;
4796 }
4797 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4798         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4799         CHECK(!val->result_ok);
4800         LDKDecodeError err_var = (*val->contents.err);
4801         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4802         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4803         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4804         return err_ref;
4805 }
4806 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
4807         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
4808 }
4809 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4810         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4811         CHECK(val->result_ok);
4812         LDKAnnouncementSignatures res_var = (*val->contents.result);
4813         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4814         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4815         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4816         return res_ref;
4817 }
4818 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4819         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4820         CHECK(!val->result_ok);
4821         LDKDecodeError err_var = (*val->contents.err);
4822         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4823         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4824         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4825         return err_ref;
4826 }
4827 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4828         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4829 }
4830 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4831         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4832         CHECK(val->result_ok);
4833         LDKChannelReestablish res_var = (*val->contents.result);
4834         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4835         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4836         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4837         return res_ref;
4838 }
4839 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4840         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4841         CHECK(!val->result_ok);
4842         LDKDecodeError err_var = (*val->contents.err);
4843         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4844         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4845         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4846         return err_ref;
4847 }
4848 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4849         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4850 }
4851 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4852         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4853         CHECK(val->result_ok);
4854         LDKClosingSigned res_var = (*val->contents.result);
4855         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4856         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4857         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4858         return res_ref;
4859 }
4860 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4861         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4862         CHECK(!val->result_ok);
4863         LDKDecodeError err_var = (*val->contents.err);
4864         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4865         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4866         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4867         return err_ref;
4868 }
4869 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
4870         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
4871 }
4872 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4873         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4874         CHECK(val->result_ok);
4875         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4876         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4877         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4878         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4879         return res_ref;
4880 }
4881 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4882         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4883         CHECK(!val->result_ok);
4884         LDKDecodeError err_var = (*val->contents.err);
4885         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4886         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4887         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4888         return err_ref;
4889 }
4890 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4891         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4892 }
4893 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4894         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4895         CHECK(val->result_ok);
4896         LDKCommitmentSigned res_var = (*val->contents.result);
4897         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4898         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4899         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4900         return res_ref;
4901 }
4902 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4903         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4904         CHECK(!val->result_ok);
4905         LDKDecodeError err_var = (*val->contents.err);
4906         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4907         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4908         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4909         return err_ref;
4910 }
4911 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4912         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4913 }
4914 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4915         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4916         CHECK(val->result_ok);
4917         LDKFundingCreated res_var = (*val->contents.result);
4918         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4919         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4920         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4921         return res_ref;
4922 }
4923 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4924         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4925         CHECK(!val->result_ok);
4926         LDKDecodeError err_var = (*val->contents.err);
4927         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4930         return err_ref;
4931 }
4932 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4933         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4934 }
4935 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4936         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4937         CHECK(val->result_ok);
4938         LDKFundingSigned res_var = (*val->contents.result);
4939         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4942         return res_ref;
4943 }
4944 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4945         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4946         CHECK(!val->result_ok);
4947         LDKDecodeError err_var = (*val->contents.err);
4948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4950         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4951         return err_ref;
4952 }
4953 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4954         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4955 }
4956 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4957         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4958         CHECK(val->result_ok);
4959         LDKFundingLocked res_var = (*val->contents.result);
4960         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4961         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4962         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4963         return res_ref;
4964 }
4965 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4966         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4967         CHECK(!val->result_ok);
4968         LDKDecodeError err_var = (*val->contents.err);
4969         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4970         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4971         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4972         return err_ref;
4973 }
4974 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4975         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4976 }
4977 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4978         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4979         CHECK(val->result_ok);
4980         LDKInit res_var = (*val->contents.result);
4981         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4982         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4983         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4984         return res_ref;
4985 }
4986 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4987         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4988         CHECK(!val->result_ok);
4989         LDKDecodeError err_var = (*val->contents.err);
4990         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4991         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4992         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4993         return err_ref;
4994 }
4995 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4996         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4997 }
4998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4999         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5000         CHECK(val->result_ok);
5001         LDKOpenChannel res_var = (*val->contents.result);
5002         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5003         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5004         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5005         return res_ref;
5006 }
5007 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
5008         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5009         CHECK(!val->result_ok);
5010         LDKDecodeError err_var = (*val->contents.err);
5011         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5012         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5013         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5014         return err_ref;
5015 }
5016 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
5017         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5018 }
5019 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
5020         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5021         CHECK(val->result_ok);
5022         LDKRevokeAndACK res_var = (*val->contents.result);
5023         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5024         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5025         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5026         return res_ref;
5027 }
5028 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
5029         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5030         CHECK(!val->result_ok);
5031         LDKDecodeError err_var = (*val->contents.err);
5032         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5033         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5034         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5035         return err_ref;
5036 }
5037 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
5038         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5039 }
5040 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
5041         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5042         CHECK(val->result_ok);
5043         LDKShutdown res_var = (*val->contents.result);
5044         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5045         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5046         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5047         return res_ref;
5048 }
5049 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
5050         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5051         CHECK(!val->result_ok);
5052         LDKDecodeError err_var = (*val->contents.err);
5053         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5054         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5055         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5056         return err_ref;
5057 }
5058 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5059         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5060 }
5061 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5062         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5063         CHECK(val->result_ok);
5064         LDKUpdateFailHTLC res_var = (*val->contents.result);
5065         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5066         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5067         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5068         return res_ref;
5069 }
5070 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
5071         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5072         CHECK(!val->result_ok);
5073         LDKDecodeError err_var = (*val->contents.err);
5074         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5075         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5076         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5077         return err_ref;
5078 }
5079 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5080         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5081 }
5082 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5083         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5084         CHECK(val->result_ok);
5085         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5086         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5087         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5088         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5089         return res_ref;
5090 }
5091 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
5092         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5093         CHECK(!val->result_ok);
5094         LDKDecodeError err_var = (*val->contents.err);
5095         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5096         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5097         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5098         return err_ref;
5099 }
5100 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
5101         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5102 }
5103 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
5104         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5105         CHECK(val->result_ok);
5106         LDKUpdateFee res_var = (*val->contents.result);
5107         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5110         return res_ref;
5111 }
5112 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
5113         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5114         CHECK(!val->result_ok);
5115         LDKDecodeError err_var = (*val->contents.err);
5116         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5117         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5118         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5119         return err_ref;
5120 }
5121 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5122         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5123 }
5124 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5125         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5126         CHECK(val->result_ok);
5127         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5128         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5129         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5130         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5131         return res_ref;
5132 }
5133 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
5134         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5135         CHECK(!val->result_ok);
5136         LDKDecodeError err_var = (*val->contents.err);
5137         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5138         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5139         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5140         return err_ref;
5141 }
5142 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
5143         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5144 }
5145 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5146         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5147         CHECK(val->result_ok);
5148         LDKUpdateAddHTLC res_var = (*val->contents.result);
5149         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5150         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5151         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5152         return res_ref;
5153 }
5154 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
5155         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5156         CHECK(!val->result_ok);
5157         LDKDecodeError err_var = (*val->contents.err);
5158         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5159         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5160         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5161         return err_ref;
5162 }
5163 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
5164         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5165 }
5166 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
5167         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5168         CHECK(val->result_ok);
5169         LDKPing res_var = (*val->contents.result);
5170         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5171         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5172         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5173         return res_ref;
5174 }
5175 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
5176         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5177         CHECK(!val->result_ok);
5178         LDKDecodeError err_var = (*val->contents.err);
5179         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5182         return err_ref;
5183 }
5184 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
5185         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5186 }
5187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
5188         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5189         CHECK(val->result_ok);
5190         LDKPong res_var = (*val->contents.result);
5191         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5192         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5193         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5194         return res_ref;
5195 }
5196 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
5197         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5198         CHECK(!val->result_ok);
5199         LDKDecodeError err_var = (*val->contents.err);
5200         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5201         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5202         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5203         return err_ref;
5204 }
5205 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5206         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5207 }
5208 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5209         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5210         CHECK(val->result_ok);
5211         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5212         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5213         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5214         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5215         return res_ref;
5216 }
5217 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5218         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5219         CHECK(!val->result_ok);
5220         LDKDecodeError err_var = (*val->contents.err);
5221         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5222         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5223         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5224         return err_ref;
5225 }
5226 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5227         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5228 }
5229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5230         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5231         CHECK(val->result_ok);
5232         LDKChannelAnnouncement res_var = (*val->contents.result);
5233         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5234         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5235         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5236         return res_ref;
5237 }
5238 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5239         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5240         CHECK(!val->result_ok);
5241         LDKDecodeError err_var = (*val->contents.err);
5242         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5243         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5244         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5245         return err_ref;
5246 }
5247 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5248         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5249 }
5250 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5251         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5252         CHECK(val->result_ok);
5253         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5254         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5255         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5256         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5257         return res_ref;
5258 }
5259 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5260         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5261         CHECK(!val->result_ok);
5262         LDKDecodeError err_var = (*val->contents.err);
5263         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5264         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5265         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5266         return err_ref;
5267 }
5268 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5269         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5270 }
5271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5272         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5273         CHECK(val->result_ok);
5274         LDKChannelUpdate res_var = (*val->contents.result);
5275         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5276         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5277         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5278         return res_ref;
5279 }
5280 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5281         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5282         CHECK(!val->result_ok);
5283         LDKDecodeError err_var = (*val->contents.err);
5284         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5287         return err_ref;
5288 }
5289 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
5290         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5291 }
5292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
5293         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5294         CHECK(val->result_ok);
5295         LDKErrorMessage res_var = (*val->contents.result);
5296         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5297         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5298         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5299         return res_ref;
5300 }
5301 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
5302         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5303         CHECK(!val->result_ok);
5304         LDKDecodeError err_var = (*val->contents.err);
5305         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5306         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5307         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5308         return err_ref;
5309 }
5310 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5311         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5312 }
5313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5314         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5315         CHECK(val->result_ok);
5316         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5317         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5318         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5319         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5320         return res_ref;
5321 }
5322 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5323         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5324         CHECK(!val->result_ok);
5325         LDKDecodeError err_var = (*val->contents.err);
5326         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5327         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5328         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5329         return err_ref;
5330 }
5331 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5332         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5333 }
5334 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5335         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5336         CHECK(val->result_ok);
5337         LDKNodeAnnouncement res_var = (*val->contents.result);
5338         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5339         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5340         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5341         return res_ref;
5342 }
5343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5344         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5345         CHECK(!val->result_ok);
5346         LDKDecodeError err_var = (*val->contents.err);
5347         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5348         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5349         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5350         return err_ref;
5351 }
5352 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
5353         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5354 }
5355 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5356         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5357         CHECK(val->result_ok);
5358         LDKQueryShortChannelIds res_var = (*val->contents.result);
5359         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5360         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5361         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5362         return res_ref;
5363 }
5364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5365         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5366         CHECK(!val->result_ok);
5367         LDKDecodeError err_var = (*val->contents.err);
5368         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5369         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5370         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5371         return err_ref;
5372 }
5373 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
5374         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5375 }
5376 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5377         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5378         CHECK(val->result_ok);
5379         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5380         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5381         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5382         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5383         return res_ref;
5384 }
5385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5386         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5387         CHECK(!val->result_ok);
5388         LDKDecodeError err_var = (*val->contents.err);
5389         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5390         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5391         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5392         return err_ref;
5393 }
5394 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5395         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5396 }
5397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5398         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5399         CHECK(val->result_ok);
5400         LDKQueryChannelRange res_var = (*val->contents.result);
5401         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5402         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5403         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5404         return res_ref;
5405 }
5406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5407         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5408         CHECK(!val->result_ok);
5409         LDKDecodeError err_var = (*val->contents.err);
5410         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5411         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5412         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5413         return err_ref;
5414 }
5415 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5416         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5417 }
5418 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5419         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5420         CHECK(val->result_ok);
5421         LDKReplyChannelRange res_var = (*val->contents.result);
5422         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5425         return res_ref;
5426 }
5427 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5428         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5429         CHECK(!val->result_ok);
5430         LDKDecodeError err_var = (*val->contents.err);
5431         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5432         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5433         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5434         return err_ref;
5435 }
5436 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
5437         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5438 }
5439 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5440         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5441         CHECK(val->result_ok);
5442         LDKGossipTimestampFilter res_var = (*val->contents.result);
5443         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5446         return res_ref;
5447 }
5448 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5449         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5450         CHECK(!val->result_ok);
5451         LDKDecodeError err_var = (*val->contents.err);
5452         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5453         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5454         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5455         return err_ref;
5456 }
5457 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5458         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5459         switch(obj->tag) {
5460                 case LDKSignOrCreationError_SignError: {
5461                         return 0 /* LDKSignOrCreationError - SignError */;
5462                 }
5463                 case LDKSignOrCreationError_CreationError: {
5464                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5465                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5466                 }
5467                 default: abort();
5468         }
5469 }
5470 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
5471         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5472 }
5473 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5474         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5475         CHECK(val->result_ok);
5476         LDKInvoice res_var = (*val->contents.result);
5477         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5478         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5479         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5480         return res_ref;
5481 }
5482 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5483         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5484         CHECK(!val->result_ok);
5485         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5486         return err_ref;
5487 }
5488 typedef struct LDKFilter_JCalls {
5489         atomic_size_t refcnt;
5490         uint32_t register_tx_meth;
5491         uint32_t register_output_meth;
5492 } LDKFilter_JCalls;
5493 static void LDKFilter_JCalls_free(void* this_arg) {
5494         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5495         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5496                 js_free(j_calls->register_tx_meth);
5497                 js_free(j_calls->register_output_meth);
5498                 FREE(j_calls);
5499         }
5500 }
5501 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5502         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5503         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5504         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5505         LDKu8slice script_pubkey_var = script_pubkey;
5506         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5507         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5508         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5509 }
5510 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5511         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5512         LDKWatchedOutput output_var = output;
5513         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5514         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5515         uint64_t output_ref = (uint64_t)output_var.inner;
5516         if (output_var.is_owned) {
5517                 output_ref |= 1;
5518         }
5519         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5520         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5521         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5522         return ret_conv;
5523 }
5524 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5525         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5526         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5527 }
5528 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5529         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5530         atomic_init(&calls->refcnt, 1);
5531         //TODO: Assign calls->o from o
5532
5533         LDKFilter ret = {
5534                 .this_arg = (void*) calls,
5535                 .register_tx = register_tx_LDKFilter_jcall,
5536                 .register_output = register_output_LDKFilter_jcall,
5537                 .free = LDKFilter_JCalls_free,
5538         };
5539         return ret;
5540 }
5541 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5542         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5543         *res_ptr = LDKFilter_init(o);
5544         return (long)res_ptr;
5545 }
5546 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5547         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5548         unsigned char txid_arr[32];
5549         CHECK(*((uint32_t*)txid) == 32);
5550         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5551         unsigned char (*txid_ref)[32] = &txid_arr;
5552         LDKu8slice script_pubkey_ref;
5553         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5554         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5555         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5556 }
5557
5558 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5559         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5560         LDKWatchedOutput output_conv;
5561         output_conv.inner = (void*)(output & (~1));
5562         output_conv.is_owned = (output & 1) || (output == 0);
5563         output_conv = WatchedOutput_clone(&output_conv);
5564         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5565         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5566         uint64_t ret_ref = (uint64_t)ret_copy;
5567         return ret_ref;
5568 }
5569
5570 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5571         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5572         switch(obj->tag) {
5573                 case LDKCOption_FilterZ_Some: {
5574                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
5575                         *some_ret = obj->some;
5576                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5577                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5578                 }
5579                 case LDKCOption_FilterZ_None: {
5580                         return 0 /* LDKCOption_FilterZ - None */;
5581                 }
5582                 default: abort();
5583         }
5584 }
5585 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_result_ok(uint32_t arg) {
5586         return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
5587 }
5588 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
5589         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5590         CHECK(val->result_ok);
5591         LDKLockedChannelMonitor res_var = (*val->contents.result);
5592         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5593         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5594         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5595         return res_ref;
5596 }
5597 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
5598         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5599         CHECK(!val->result_ok);
5600         return *val->contents.err;
5601 }
5602 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_OutPointZ_new(uint32_tArray elems) {
5603         LDKCVec_OutPointZ *ret = MALLOC(sizeof(LDKCVec_OutPointZ), "LDKCVec_OutPointZ");
5604         ret->datalen = *((uint32_t*)elems);
5605         if (ret->datalen == 0) {
5606                 ret->data = NULL;
5607         } else {
5608                 ret->data = MALLOC(sizeof(LDKOutPoint) * ret->datalen, "LDKCVec_OutPointZ Data");
5609                 uint32_t *java_elems = (uint32_t*)(elems + 4);
5610                 for (size_t i = 0; i < ret->datalen; i++) {
5611                         uint32_t arr_elem = java_elems[i];
5612                         LDKOutPoint arr_elem_conv;
5613                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5614                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5615                         arr_elem_conv = OutPoint_clone(&arr_elem_conv);
5616                         ret->data[i] = arr_elem_conv;
5617                 }
5618         }
5619         return (uint64_t)ret;
5620 }
5621 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5622         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5623         for (size_t i = 0; i < ret.datalen; i++) {
5624                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5625         }
5626         return ret;
5627 }
5628 typedef struct LDKMessageSendEventsProvider_JCalls {
5629         atomic_size_t refcnt;
5630         uint32_t get_and_clear_pending_msg_events_meth;
5631 } LDKMessageSendEventsProvider_JCalls;
5632 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5633         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5634         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5635                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5636                 FREE(j_calls);
5637         }
5638 }
5639 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5640         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5641         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5642         LDKCVec_MessageSendEventZ ret_constr;
5643         ret_constr.datalen = *((uint32_t*)ret);
5644         if (ret_constr.datalen > 0)
5645                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5646         else
5647                 ret_constr.data = NULL;
5648         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5649         for (size_t s = 0; s < ret_constr.datalen; s++) {
5650                 uint32_t ret_conv_18 = ret_vals[s];
5651                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5652                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5653                 ret_constr.data[s] = ret_conv_18_conv;
5654         }
5655         return ret_constr;
5656 }
5657 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5658         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5659         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5660 }
5661 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5662         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5663         atomic_init(&calls->refcnt, 1);
5664         //TODO: Assign calls->o from o
5665
5666         LDKMessageSendEventsProvider ret = {
5667                 .this_arg = (void*) calls,
5668                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
5669                 .free = LDKMessageSendEventsProvider_JCalls_free,
5670         };
5671         return ret;
5672 }
5673 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5674         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5675         *res_ptr = LDKMessageSendEventsProvider_init(o);
5676         return (long)res_ptr;
5677 }
5678 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
5679         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
5680         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5681         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5682         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5683         for (size_t s = 0; s < ret_var.datalen; s++) {
5684                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5685                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
5686                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
5687                 ret_arr_ptr[s] = ret_conv_18_ref;
5688         }
5689         FREE(ret_var.data);
5690         return ret_arr;
5691 }
5692
5693 typedef struct LDKEventHandler_JCalls {
5694         atomic_size_t refcnt;
5695         uint32_t handle_event_meth;
5696 } LDKEventHandler_JCalls;
5697 static void LDKEventHandler_JCalls_free(void* this_arg) {
5698         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5699         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5700                 js_free(j_calls->handle_event_meth);
5701                 FREE(j_calls);
5702         }
5703 }
5704 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
5705         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5706         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
5707         *ret_event = Event_clone(event);
5708         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
5709 }
5710 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
5711         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
5712         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5713 }
5714 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
5715         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
5716         atomic_init(&calls->refcnt, 1);
5717         //TODO: Assign calls->o from o
5718
5719         LDKEventHandler ret = {
5720                 .this_arg = (void*) calls,
5721                 .handle_event = handle_event_LDKEventHandler_jcall,
5722                 .free = LDKEventHandler_JCalls_free,
5723         };
5724         return ret;
5725 }
5726 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
5727         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5728         *res_ptr = LDKEventHandler_init(o);
5729         return (long)res_ptr;
5730 }
5731 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
5732         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
5733         LDKEvent* event_conv = (LDKEvent*)event;
5734         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
5735 }
5736
5737 typedef struct LDKEventsProvider_JCalls {
5738         atomic_size_t refcnt;
5739         uint32_t process_pending_events_meth;
5740 } LDKEventsProvider_JCalls;
5741 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5742         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5743         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5744                 js_free(j_calls->process_pending_events_meth);
5745                 FREE(j_calls);
5746         }
5747 }
5748 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
5749         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5750         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5751         *handler_ret = handler;
5752         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
5753 }
5754 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
5755         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
5756         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5757 }
5758 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5759         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5760         atomic_init(&calls->refcnt, 1);
5761         //TODO: Assign calls->o from o
5762
5763         LDKEventsProvider ret = {
5764                 .this_arg = (void*) calls,
5765                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
5766                 .free = LDKEventsProvider_JCalls_free,
5767         };
5768         return ret;
5769 }
5770 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5771         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5772         *res_ptr = LDKEventsProvider_init(o);
5773         return (long)res_ptr;
5774 }
5775 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
5776         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
5777         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
5778         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
5779 }
5780
5781 typedef struct LDKListen_JCalls {
5782         atomic_size_t refcnt;
5783         uint32_t block_connected_meth;
5784         uint32_t block_disconnected_meth;
5785 } LDKListen_JCalls;
5786 static void LDKListen_JCalls_free(void* this_arg) {
5787         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5788         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5789                 js_free(j_calls->block_connected_meth);
5790                 js_free(j_calls->block_disconnected_meth);
5791                 FREE(j_calls);
5792         }
5793 }
5794 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5795         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5796         LDKu8slice block_var = block;
5797         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5798         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
5799         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
5800 }
5801 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5802         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5803         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5804         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5805         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
5806 }
5807 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5808         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5809         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5810 }
5811 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5812         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5813         atomic_init(&calls->refcnt, 1);
5814         //TODO: Assign calls->o from o
5815
5816         LDKListen ret = {
5817                 .this_arg = (void*) calls,
5818                 .block_connected = block_connected_LDKListen_jcall,
5819                 .block_disconnected = block_disconnected_LDKListen_jcall,
5820                 .free = LDKListen_JCalls_free,
5821         };
5822         return ret;
5823 }
5824 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5825         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5826         *res_ptr = LDKListen_init(o);
5827         return (long)res_ptr;
5828 }
5829 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5830         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5831         LDKu8slice block_ref;
5832         block_ref.datalen = *((uint32_t*)block);
5833         block_ref.data = (int8_t*)(block + 4);
5834         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5835 }
5836
5837 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5838         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5839         unsigned char header_arr[80];
5840         CHECK(*((uint32_t*)header) == 80);
5841         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5842         unsigned char (*header_ref)[80] = &header_arr;
5843         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5844 }
5845
5846 typedef struct LDKConfirm_JCalls {
5847         atomic_size_t refcnt;
5848         uint32_t transactions_confirmed_meth;
5849         uint32_t transaction_unconfirmed_meth;
5850         uint32_t best_block_updated_meth;
5851         uint32_t get_relevant_txids_meth;
5852 } LDKConfirm_JCalls;
5853 static void LDKConfirm_JCalls_free(void* this_arg) {
5854         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5855         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5856                 js_free(j_calls->transactions_confirmed_meth);
5857                 js_free(j_calls->transaction_unconfirmed_meth);
5858                 js_free(j_calls->best_block_updated_meth);
5859                 js_free(j_calls->get_relevant_txids_meth);
5860                 FREE(j_calls);
5861         }
5862 }
5863 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5864         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5865         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5866         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5867         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5868         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5869         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5870         for (size_t c = 0; c < txdata_var.datalen; c++) {
5871                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5872                 *txdata_conv_28_conv = txdata_var.data[c];
5873                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
5874         }
5875         FREE(txdata_var.data);
5876         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5877 }
5878 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5879         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5880         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5881         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5882         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5883 }
5884 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5885         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5886         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5887         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5888         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5889 }
5890 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5891         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5892         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5893         LDKCVec_TxidZ ret_constr;
5894         ret_constr.datalen = *((uint32_t*)ret);
5895         if (ret_constr.datalen > 0)
5896                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5897         else
5898                 ret_constr.data = NULL;
5899         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5900         for (size_t m = 0; m < ret_constr.datalen; m++) {
5901                 int8_tArray ret_conv_12 = ret_vals[m];
5902                 LDKThirtyTwoBytes ret_conv_12_ref;
5903                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5904                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5905                 ret_constr.data[m] = ret_conv_12_ref;
5906         }
5907         return ret_constr;
5908 }
5909 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5910         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5911         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5912 }
5913 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5914         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5915         atomic_init(&calls->refcnt, 1);
5916         //TODO: Assign calls->o from o
5917
5918         LDKConfirm ret = {
5919                 .this_arg = (void*) calls,
5920                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5921                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5922                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5923                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5924                 .free = LDKConfirm_JCalls_free,
5925         };
5926         return ret;
5927 }
5928 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5929         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5930         *res_ptr = LDKConfirm_init(o);
5931         return (long)res_ptr;
5932 }
5933 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5934         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5935         unsigned char header_arr[80];
5936         CHECK(*((uint32_t*)header) == 80);
5937         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5938         unsigned char (*header_ref)[80] = &header_arr;
5939         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5940         txdata_constr.datalen = *((uint32_t*)txdata);
5941         if (txdata_constr.datalen > 0)
5942                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5943         else
5944                 txdata_constr.data = NULL;
5945         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5946         for (size_t c = 0; c < txdata_constr.datalen; c++) {
5947                 uint32_t txdata_conv_28 = txdata_vals[c];
5948                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
5949                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
5950                 txdata_constr.data[c] = txdata_conv_28_conv;
5951         }
5952         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5953 }
5954
5955 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5956         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5957         unsigned char txid_arr[32];
5958         CHECK(*((uint32_t*)txid) == 32);
5959         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5960         unsigned char (*txid_ref)[32] = &txid_arr;
5961         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5962 }
5963
5964 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5965         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5966         unsigned char header_arr[80];
5967         CHECK(*((uint32_t*)header) == 80);
5968         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5969         unsigned char (*header_ref)[80] = &header_arr;
5970         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5971 }
5972
5973 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5974         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5975         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5976         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5977         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5978         for (size_t m = 0; m < ret_var.datalen; m++) {
5979                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5980                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5981                 ret_arr_ptr[m] = ret_conv_12_arr;
5982         }
5983         FREE(ret_var.data);
5984         return ret_arr;
5985 }
5986
5987 typedef struct LDKPersist_JCalls {
5988         atomic_size_t refcnt;
5989         uint32_t persist_new_channel_meth;
5990         uint32_t update_persisted_channel_meth;
5991 } LDKPersist_JCalls;
5992 static void LDKPersist_JCalls_free(void* this_arg) {
5993         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5994         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5995                 js_free(j_calls->persist_new_channel_meth);
5996                 js_free(j_calls->update_persisted_channel_meth);
5997                 FREE(j_calls);
5998         }
5999 }
6000 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6001         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6002         LDKOutPoint id_var = id;
6003         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         uint64_t id_ref = (uint64_t)id_var.inner;
6006         if (id_var.is_owned) {
6007                 id_ref |= 1;
6008         }
6009         LDKChannelMonitor data_var = *data;
6010         data_var = ChannelMonitor_clone(data);
6011         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6012         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6013         uint64_t data_ref = (uint64_t)data_var.inner;
6014         if (data_var.is_owned) {
6015                 data_ref |= 1;
6016         }
6017         uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
6018         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6019         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6020         return ret_conv;
6021 }
6022 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6023         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6024         LDKOutPoint id_var = id;
6025         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6026         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6027         uint64_t id_ref = (uint64_t)id_var.inner;
6028         if (id_var.is_owned) {
6029                 id_ref |= 1;
6030         }
6031         LDKChannelMonitorUpdate update_var = *update;
6032         update_var = ChannelMonitorUpdate_clone(update);
6033         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6034         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6035         uint64_t update_ref = (uint64_t)update_var.inner;
6036         if (update_var.is_owned) {
6037                 update_ref |= 1;
6038         }
6039         LDKChannelMonitor data_var = *data;
6040         data_var = ChannelMonitor_clone(data);
6041         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6042         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6043         uint64_t data_ref = (uint64_t)data_var.inner;
6044         if (data_var.is_owned) {
6045                 data_ref |= 1;
6046         }
6047         uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
6048         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6049         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6050         return ret_conv;
6051 }
6052 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
6053         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
6054         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6055 }
6056 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
6057         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6058         atomic_init(&calls->refcnt, 1);
6059         //TODO: Assign calls->o from o
6060
6061         LDKPersist ret = {
6062                 .this_arg = (void*) calls,
6063                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6064                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6065                 .free = LDKPersist_JCalls_free,
6066         };
6067         return ret;
6068 }
6069 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
6070         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6071         *res_ptr = LDKPersist_init(o);
6072         return (long)res_ptr;
6073 }
6074 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
6075         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6076         LDKOutPoint id_conv;
6077         id_conv.inner = (void*)(id & (~1));
6078         id_conv.is_owned = (id & 1) || (id == 0);
6079         id_conv = OutPoint_clone(&id_conv);
6080         LDKChannelMonitor data_conv;
6081         data_conv.inner = (void*)(data & (~1));
6082         data_conv.is_owned = false;
6083         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6084         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
6085         return (uint64_t)ret_conv;
6086 }
6087
6088 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
6089         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
6090         LDKOutPoint id_conv;
6091         id_conv.inner = (void*)(id & (~1));
6092         id_conv.is_owned = (id & 1) || (id == 0);
6093         id_conv = OutPoint_clone(&id_conv);
6094         LDKChannelMonitorUpdate update_conv;
6095         update_conv.inner = (void*)(update & (~1));
6096         update_conv.is_owned = false;
6097         LDKChannelMonitor data_conv;
6098         data_conv.inner = (void*)(data & (~1));
6099         data_conv.is_owned = false;
6100         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6101         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
6102         return (uint64_t)ret_conv;
6103 }
6104
6105 typedef struct LDKChannelMessageHandler_JCalls {
6106         atomic_size_t refcnt;
6107         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6108         uint32_t handle_open_channel_meth;
6109         uint32_t handle_accept_channel_meth;
6110         uint32_t handle_funding_created_meth;
6111         uint32_t handle_funding_signed_meth;
6112         uint32_t handle_funding_locked_meth;
6113         uint32_t handle_shutdown_meth;
6114         uint32_t handle_closing_signed_meth;
6115         uint32_t handle_update_add_htlc_meth;
6116         uint32_t handle_update_fulfill_htlc_meth;
6117         uint32_t handle_update_fail_htlc_meth;
6118         uint32_t handle_update_fail_malformed_htlc_meth;
6119         uint32_t handle_commitment_signed_meth;
6120         uint32_t handle_revoke_and_ack_meth;
6121         uint32_t handle_update_fee_meth;
6122         uint32_t handle_announcement_signatures_meth;
6123         uint32_t peer_disconnected_meth;
6124         uint32_t peer_connected_meth;
6125         uint32_t handle_channel_reestablish_meth;
6126         uint32_t handle_channel_update_meth;
6127         uint32_t handle_error_meth;
6128 } LDKChannelMessageHandler_JCalls;
6129 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6130         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6131         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6132                 js_free(j_calls->handle_open_channel_meth);
6133                 js_free(j_calls->handle_accept_channel_meth);
6134                 js_free(j_calls->handle_funding_created_meth);
6135                 js_free(j_calls->handle_funding_signed_meth);
6136                 js_free(j_calls->handle_funding_locked_meth);
6137                 js_free(j_calls->handle_shutdown_meth);
6138                 js_free(j_calls->handle_closing_signed_meth);
6139                 js_free(j_calls->handle_update_add_htlc_meth);
6140                 js_free(j_calls->handle_update_fulfill_htlc_meth);
6141                 js_free(j_calls->handle_update_fail_htlc_meth);
6142                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
6143                 js_free(j_calls->handle_commitment_signed_meth);
6144                 js_free(j_calls->handle_revoke_and_ack_meth);
6145                 js_free(j_calls->handle_update_fee_meth);
6146                 js_free(j_calls->handle_announcement_signatures_meth);
6147                 js_free(j_calls->peer_disconnected_meth);
6148                 js_free(j_calls->peer_connected_meth);
6149                 js_free(j_calls->handle_channel_reestablish_meth);
6150                 js_free(j_calls->handle_channel_update_meth);
6151                 js_free(j_calls->handle_error_meth);
6152                 FREE(j_calls);
6153         }
6154 }
6155 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6156         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6157         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6158         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6159         LDKInitFeatures their_features_var = their_features;
6160         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6161         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6162         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6163         if (their_features_var.is_owned) {
6164                 their_features_ref |= 1;
6165         }
6166         LDKOpenChannel msg_var = *msg;
6167         msg_var = OpenChannel_clone(msg);
6168         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         uint64_t msg_ref = (uint64_t)msg_var.inner;
6171         if (msg_var.is_owned) {
6172                 msg_ref |= 1;
6173         }
6174         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6175 }
6176 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6177         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6178         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6179         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6180         LDKInitFeatures their_features_var = their_features;
6181         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6182         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6183         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6184         if (their_features_var.is_owned) {
6185                 their_features_ref |= 1;
6186         }
6187         LDKAcceptChannel msg_var = *msg;
6188         msg_var = AcceptChannel_clone(msg);
6189         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6190         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6191         uint64_t msg_ref = (uint64_t)msg_var.inner;
6192         if (msg_var.is_owned) {
6193                 msg_ref |= 1;
6194         }
6195         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6196 }
6197 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6199         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6200         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6201         LDKFundingCreated msg_var = *msg;
6202         msg_var = FundingCreated_clone(msg);
6203         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6204         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6205         uint64_t msg_ref = (uint64_t)msg_var.inner;
6206         if (msg_var.is_owned) {
6207                 msg_ref |= 1;
6208         }
6209         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
6210 }
6211 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
6212         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6213         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6214         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6215         LDKFundingSigned msg_var = *msg;
6216         msg_var = FundingSigned_clone(msg);
6217         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6218         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6219         uint64_t msg_ref = (uint64_t)msg_var.inner;
6220         if (msg_var.is_owned) {
6221                 msg_ref |= 1;
6222         }
6223         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
6224 }
6225 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
6226         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6227         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6228         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6229         LDKFundingLocked msg_var = *msg;
6230         msg_var = FundingLocked_clone(msg);
6231         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6232         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6233         uint64_t msg_ref = (uint64_t)msg_var.inner;
6234         if (msg_var.is_owned) {
6235                 msg_ref |= 1;
6236         }
6237         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
6238 }
6239 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
6240         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6241         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6242         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6243         LDKInitFeatures their_features_var = *their_features;
6244         their_features_var = InitFeatures_clone(their_features);
6245         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6246         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6247         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6248         if (their_features_var.is_owned) {
6249                 their_features_ref |= 1;
6250         }
6251         LDKShutdown msg_var = *msg;
6252         msg_var = Shutdown_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_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
6260 }
6261 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
6262         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6263         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6264         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6265         LDKClosingSigned msg_var = *msg;
6266         msg_var = ClosingSigned_clone(msg);
6267         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6268         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6269         uint64_t msg_ref = (uint64_t)msg_var.inner;
6270         if (msg_var.is_owned) {
6271                 msg_ref |= 1;
6272         }
6273         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
6274 }
6275 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
6276         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6277         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6278         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6279         LDKUpdateAddHTLC msg_var = *msg;
6280         msg_var = UpdateAddHTLC_clone(msg);
6281         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6282         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6283         uint64_t msg_ref = (uint64_t)msg_var.inner;
6284         if (msg_var.is_owned) {
6285                 msg_ref |= 1;
6286         }
6287         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
6288 }
6289 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
6290         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6291         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6292         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6293         LDKUpdateFulfillHTLC msg_var = *msg;
6294         msg_var = UpdateFulfillHTLC_clone(msg);
6295         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6296         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6297         uint64_t msg_ref = (uint64_t)msg_var.inner;
6298         if (msg_var.is_owned) {
6299                 msg_ref |= 1;
6300         }
6301         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
6302 }
6303 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
6304         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6305         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6306         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6307         LDKUpdateFailHTLC msg_var = *msg;
6308         msg_var = UpdateFailHTLC_clone(msg);
6309         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6310         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6311         uint64_t msg_ref = (uint64_t)msg_var.inner;
6312         if (msg_var.is_owned) {
6313                 msg_ref |= 1;
6314         }
6315         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
6316 }
6317 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
6318         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6319         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6320         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6321         LDKUpdateFailMalformedHTLC msg_var = *msg;
6322         msg_var = UpdateFailMalformedHTLC_clone(msg);
6323         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6324         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6325         uint64_t msg_ref = (uint64_t)msg_var.inner;
6326         if (msg_var.is_owned) {
6327                 msg_ref |= 1;
6328         }
6329         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
6330 }
6331 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
6332         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6333         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6334         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6335         LDKCommitmentSigned msg_var = *msg;
6336         msg_var = CommitmentSigned_clone(msg);
6337         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6338         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6339         uint64_t msg_ref = (uint64_t)msg_var.inner;
6340         if (msg_var.is_owned) {
6341                 msg_ref |= 1;
6342         }
6343         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
6344 }
6345 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
6346         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6347         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6348         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6349         LDKRevokeAndACK msg_var = *msg;
6350         msg_var = RevokeAndACK_clone(msg);
6351         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6352         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6353         uint64_t msg_ref = (uint64_t)msg_var.inner;
6354         if (msg_var.is_owned) {
6355                 msg_ref |= 1;
6356         }
6357         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6358 }
6359 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6360         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6361         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6362         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6363         LDKUpdateFee msg_var = *msg;
6364         msg_var = UpdateFee_clone(msg);
6365         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6366         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6367         uint64_t msg_ref = (uint64_t)msg_var.inner;
6368         if (msg_var.is_owned) {
6369                 msg_ref |= 1;
6370         }
6371         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6372 }
6373 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6374         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6375         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6376         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6377         LDKAnnouncementSignatures msg_var = *msg;
6378         msg_var = AnnouncementSignatures_clone(msg);
6379         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6380         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6381         uint64_t msg_ref = (uint64_t)msg_var.inner;
6382         if (msg_var.is_owned) {
6383                 msg_ref |= 1;
6384         }
6385         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6386 }
6387 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6388         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6389         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6390         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6391         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6392 }
6393 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6394         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6395         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6396         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6397         LDKInit msg_var = *msg;
6398         msg_var = Init_clone(msg);
6399         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6400         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6401         uint64_t msg_ref = (uint64_t)msg_var.inner;
6402         if (msg_var.is_owned) {
6403                 msg_ref |= 1;
6404         }
6405         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6406 }
6407 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6408         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6409         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6410         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6411         LDKChannelReestablish msg_var = *msg;
6412         msg_var = ChannelReestablish_clone(msg);
6413         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6414         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6415         uint64_t msg_ref = (uint64_t)msg_var.inner;
6416         if (msg_var.is_owned) {
6417                 msg_ref |= 1;
6418         }
6419         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6420 }
6421 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6422         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6423         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6424         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6425         LDKChannelUpdate msg_var = *msg;
6426         msg_var = ChannelUpdate_clone(msg);
6427         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6428         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6429         uint64_t msg_ref = (uint64_t)msg_var.inner;
6430         if (msg_var.is_owned) {
6431                 msg_ref |= 1;
6432         }
6433         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6434 }
6435 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6436         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6437         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6438         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6439         LDKErrorMessage msg_var = *msg;
6440         msg_var = ErrorMessage_clone(msg);
6441         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6442         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6443         uint64_t msg_ref = (uint64_t)msg_var.inner;
6444         if (msg_var.is_owned) {
6445                 msg_ref |= 1;
6446         }
6447         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6448 }
6449 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6450         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6451         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6452         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6453 }
6454 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6455         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6456         atomic_init(&calls->refcnt, 1);
6457         //TODO: Assign calls->o from o
6458
6459         LDKChannelMessageHandler ret = {
6460                 .this_arg = (void*) calls,
6461                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6462                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6463                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6464                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6465                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6466                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6467                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6468                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6469                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6470                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6471                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6472                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6473                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6474                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6475                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6476                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6477                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6478                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6479                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6480                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6481                 .free = LDKChannelMessageHandler_JCalls_free,
6482                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6483         };
6484         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6485         return ret;
6486 }
6487 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6488         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6489         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6490         return (long)res_ptr;
6491 }
6492 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) {
6493         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6494         LDKPublicKey their_node_id_ref;
6495         CHECK(*((uint32_t*)their_node_id) == 33);
6496         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6497         LDKInitFeatures their_features_conv;
6498         their_features_conv.inner = (void*)(their_features & (~1));
6499         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6500         their_features_conv = InitFeatures_clone(&their_features_conv);
6501         LDKOpenChannel msg_conv;
6502         msg_conv.inner = (void*)(msg & (~1));
6503         msg_conv.is_owned = false;
6504         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6505 }
6506
6507 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) {
6508         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6509         LDKPublicKey their_node_id_ref;
6510         CHECK(*((uint32_t*)their_node_id) == 33);
6511         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6512         LDKInitFeatures their_features_conv;
6513         their_features_conv.inner = (void*)(their_features & (~1));
6514         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6515         their_features_conv = InitFeatures_clone(&their_features_conv);
6516         LDKAcceptChannel msg_conv;
6517         msg_conv.inner = (void*)(msg & (~1));
6518         msg_conv.is_owned = false;
6519         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6520 }
6521
6522 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6523         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6524         LDKPublicKey their_node_id_ref;
6525         CHECK(*((uint32_t*)their_node_id) == 33);
6526         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6527         LDKFundingCreated msg_conv;
6528         msg_conv.inner = (void*)(msg & (~1));
6529         msg_conv.is_owned = false;
6530         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6531 }
6532
6533 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6534         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6535         LDKPublicKey their_node_id_ref;
6536         CHECK(*((uint32_t*)their_node_id) == 33);
6537         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6538         LDKFundingSigned msg_conv;
6539         msg_conv.inner = (void*)(msg & (~1));
6540         msg_conv.is_owned = false;
6541         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6542 }
6543
6544 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6545         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6546         LDKPublicKey their_node_id_ref;
6547         CHECK(*((uint32_t*)their_node_id) == 33);
6548         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6549         LDKFundingLocked msg_conv;
6550         msg_conv.inner = (void*)(msg & (~1));
6551         msg_conv.is_owned = false;
6552         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6553 }
6554
6555 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6556         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6557         LDKPublicKey their_node_id_ref;
6558         CHECK(*((uint32_t*)their_node_id) == 33);
6559         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6560         LDKInitFeatures their_features_conv;
6561         their_features_conv.inner = (void*)(their_features & (~1));
6562         their_features_conv.is_owned = false;
6563         LDKShutdown msg_conv;
6564         msg_conv.inner = (void*)(msg & (~1));
6565         msg_conv.is_owned = false;
6566         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6567 }
6568
6569 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6570         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6571         LDKPublicKey their_node_id_ref;
6572         CHECK(*((uint32_t*)their_node_id) == 33);
6573         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6574         LDKClosingSigned msg_conv;
6575         msg_conv.inner = (void*)(msg & (~1));
6576         msg_conv.is_owned = false;
6577         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6578 }
6579
6580 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6581         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6582         LDKPublicKey their_node_id_ref;
6583         CHECK(*((uint32_t*)their_node_id) == 33);
6584         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6585         LDKUpdateAddHTLC msg_conv;
6586         msg_conv.inner = (void*)(msg & (~1));
6587         msg_conv.is_owned = false;
6588         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6589 }
6590
6591 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6592         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6593         LDKPublicKey their_node_id_ref;
6594         CHECK(*((uint32_t*)their_node_id) == 33);
6595         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6596         LDKUpdateFulfillHTLC msg_conv;
6597         msg_conv.inner = (void*)(msg & (~1));
6598         msg_conv.is_owned = false;
6599         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6600 }
6601
6602 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6603         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6604         LDKPublicKey their_node_id_ref;
6605         CHECK(*((uint32_t*)their_node_id) == 33);
6606         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6607         LDKUpdateFailHTLC msg_conv;
6608         msg_conv.inner = (void*)(msg & (~1));
6609         msg_conv.is_owned = false;
6610         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6611 }
6612
6613 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6614         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6615         LDKPublicKey their_node_id_ref;
6616         CHECK(*((uint32_t*)their_node_id) == 33);
6617         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6618         LDKUpdateFailMalformedHTLC msg_conv;
6619         msg_conv.inner = (void*)(msg & (~1));
6620         msg_conv.is_owned = false;
6621         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6622 }
6623
6624 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6625         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6626         LDKPublicKey their_node_id_ref;
6627         CHECK(*((uint32_t*)their_node_id) == 33);
6628         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6629         LDKCommitmentSigned msg_conv;
6630         msg_conv.inner = (void*)(msg & (~1));
6631         msg_conv.is_owned = false;
6632         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6633 }
6634
6635 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6636         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6637         LDKPublicKey their_node_id_ref;
6638         CHECK(*((uint32_t*)their_node_id) == 33);
6639         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6640         LDKRevokeAndACK msg_conv;
6641         msg_conv.inner = (void*)(msg & (~1));
6642         msg_conv.is_owned = false;
6643         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6644 }
6645
6646 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6647         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6648         LDKPublicKey their_node_id_ref;
6649         CHECK(*((uint32_t*)their_node_id) == 33);
6650         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6651         LDKUpdateFee msg_conv;
6652         msg_conv.inner = (void*)(msg & (~1));
6653         msg_conv.is_owned = false;
6654         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6655 }
6656
6657 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6658         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6659         LDKPublicKey their_node_id_ref;
6660         CHECK(*((uint32_t*)their_node_id) == 33);
6661         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6662         LDKAnnouncementSignatures msg_conv;
6663         msg_conv.inner = (void*)(msg & (~1));
6664         msg_conv.is_owned = false;
6665         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6666 }
6667
6668 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
6669         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6670         LDKPublicKey their_node_id_ref;
6671         CHECK(*((uint32_t*)their_node_id) == 33);
6672         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6673         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6674 }
6675
6676 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6677         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6678         LDKPublicKey their_node_id_ref;
6679         CHECK(*((uint32_t*)their_node_id) == 33);
6680         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6681         LDKInit msg_conv;
6682         msg_conv.inner = (void*)(msg & (~1));
6683         msg_conv.is_owned = false;
6684         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6685 }
6686
6687 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6688         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6689         LDKPublicKey their_node_id_ref;
6690         CHECK(*((uint32_t*)their_node_id) == 33);
6691         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6692         LDKChannelReestablish msg_conv;
6693         msg_conv.inner = (void*)(msg & (~1));
6694         msg_conv.is_owned = false;
6695         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6696 }
6697
6698 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6699         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6700         LDKPublicKey their_node_id_ref;
6701         CHECK(*((uint32_t*)their_node_id) == 33);
6702         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6703         LDKChannelUpdate msg_conv;
6704         msg_conv.inner = (void*)(msg & (~1));
6705         msg_conv.is_owned = false;
6706         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6707 }
6708
6709 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6710         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6711         LDKPublicKey their_node_id_ref;
6712         CHECK(*((uint32_t*)their_node_id) == 33);
6713         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6714         LDKErrorMessage msg_conv;
6715         msg_conv.inner = (void*)(msg & (~1));
6716         msg_conv.is_owned = false;
6717         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6718 }
6719
6720 typedef struct LDKRoutingMessageHandler_JCalls {
6721         atomic_size_t refcnt;
6722         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6723         uint32_t handle_node_announcement_meth;
6724         uint32_t handle_channel_announcement_meth;
6725         uint32_t handle_channel_update_meth;
6726         uint32_t get_next_channel_announcements_meth;
6727         uint32_t get_next_node_announcements_meth;
6728         uint32_t sync_routing_table_meth;
6729         uint32_t handle_reply_channel_range_meth;
6730         uint32_t handle_reply_short_channel_ids_end_meth;
6731         uint32_t handle_query_channel_range_meth;
6732         uint32_t handle_query_short_channel_ids_meth;
6733 } LDKRoutingMessageHandler_JCalls;
6734 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6735         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6736         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6737                 js_free(j_calls->handle_node_announcement_meth);
6738                 js_free(j_calls->handle_channel_announcement_meth);
6739                 js_free(j_calls->handle_channel_update_meth);
6740                 js_free(j_calls->get_next_channel_announcements_meth);
6741                 js_free(j_calls->get_next_node_announcements_meth);
6742                 js_free(j_calls->sync_routing_table_meth);
6743                 js_free(j_calls->handle_reply_channel_range_meth);
6744                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6745                 js_free(j_calls->handle_query_channel_range_meth);
6746                 js_free(j_calls->handle_query_short_channel_ids_meth);
6747                 FREE(j_calls);
6748         }
6749 }
6750 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6751         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6752         LDKNodeAnnouncement msg_var = *msg;
6753         msg_var = NodeAnnouncement_clone(msg);
6754         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6755         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6756         uint64_t msg_ref = (uint64_t)msg_var.inner;
6757         if (msg_var.is_owned) {
6758                 msg_ref |= 1;
6759         }
6760         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6761         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6762         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6763         return ret_conv;
6764 }
6765 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6766         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6767         LDKChannelAnnouncement msg_var = *msg;
6768         msg_var = ChannelAnnouncement_clone(msg);
6769         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6770         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6771         uint64_t msg_ref = (uint64_t)msg_var.inner;
6772         if (msg_var.is_owned) {
6773                 msg_ref |= 1;
6774         }
6775         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6776         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6777         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6778         return ret_conv;
6779 }
6780 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6781         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6782         LDKChannelUpdate msg_var = *msg;
6783         msg_var = ChannelUpdate_clone(msg);
6784         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6785         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6786         uint64_t msg_ref = (uint64_t)msg_var.inner;
6787         if (msg_var.is_owned) {
6788                 msg_ref |= 1;
6789         }
6790         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6791         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6792         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6793         return ret_conv;
6794 }
6795 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6796         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6797         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6798         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6799         ret_constr.datalen = *((uint32_t*)ret);
6800         if (ret_constr.datalen > 0)
6801                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6802         else
6803                 ret_constr.data = NULL;
6804         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6805         for (size_t h = 0; h < ret_constr.datalen; h++) {
6806                 uint32_t ret_conv_59 = ret_vals[h];
6807                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
6808                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
6809                 ret_constr.data[h] = ret_conv_59_conv;
6810         }
6811         return ret_constr;
6812 }
6813 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6814         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6815         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6816         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6817         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6818         LDKCVec_NodeAnnouncementZ ret_constr;
6819         ret_constr.datalen = *((uint32_t*)ret);
6820         if (ret_constr.datalen > 0)
6821                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6822         else
6823                 ret_constr.data = NULL;
6824         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6825         for (size_t s = 0; s < ret_constr.datalen; s++) {
6826                 uint32_t ret_conv_18 = ret_vals[s];
6827                 LDKNodeAnnouncement ret_conv_18_conv;
6828                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6829                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6830                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6831                 ret_constr.data[s] = ret_conv_18_conv;
6832         }
6833         return ret_constr;
6834 }
6835 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6836         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6837         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6838         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6839         LDKInit init_var = *init;
6840         init_var = Init_clone(init);
6841         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6842         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6843         uint64_t init_ref = (uint64_t)init_var.inner;
6844         if (init_var.is_owned) {
6845                 init_ref |= 1;
6846         }
6847         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6848 }
6849 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6850         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6851         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6852         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6853         LDKReplyChannelRange msg_var = msg;
6854         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6855         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6856         uint64_t msg_ref = (uint64_t)msg_var.inner;
6857         if (msg_var.is_owned) {
6858                 msg_ref |= 1;
6859         }
6860         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6861         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6862         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6863         return ret_conv;
6864 }
6865 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6866         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6867         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6868         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6869         LDKReplyShortChannelIdsEnd msg_var = msg;
6870         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6871         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6872         uint64_t msg_ref = (uint64_t)msg_var.inner;
6873         if (msg_var.is_owned) {
6874                 msg_ref |= 1;
6875         }
6876         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6877         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6878         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6879         return ret_conv;
6880 }
6881 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6882         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6883         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6884         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6885         LDKQueryChannelRange msg_var = msg;
6886         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6887         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6888         uint64_t msg_ref = (uint64_t)msg_var.inner;
6889         if (msg_var.is_owned) {
6890                 msg_ref |= 1;
6891         }
6892         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6893         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6894         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6895         return ret_conv;
6896 }
6897 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6898         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6899         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6900         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6901         LDKQueryShortChannelIds msg_var = msg;
6902         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6903         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6904         uint64_t msg_ref = (uint64_t)msg_var.inner;
6905         if (msg_var.is_owned) {
6906                 msg_ref |= 1;
6907         }
6908         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6909         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6910         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6911         return ret_conv;
6912 }
6913 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
6914         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
6915         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6916         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6917 }
6918 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6919         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6920         atomic_init(&calls->refcnt, 1);
6921         //TODO: Assign calls->o from o
6922
6923         LDKRoutingMessageHandler ret = {
6924                 .this_arg = (void*) calls,
6925                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6926                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6927                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6928                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6929                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6930                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6931                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6932                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6933                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6934                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6935                 .free = LDKRoutingMessageHandler_JCalls_free,
6936                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6937         };
6938         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6939         return ret;
6940 }
6941 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6942         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6943         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6944         return (long)res_ptr;
6945 }
6946 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6947         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6948         LDKNodeAnnouncement msg_conv;
6949         msg_conv.inner = (void*)(msg & (~1));
6950         msg_conv.is_owned = false;
6951         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6952         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6953         return (uint64_t)ret_conv;
6954 }
6955
6956 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6957         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6958         LDKChannelAnnouncement msg_conv;
6959         msg_conv.inner = (void*)(msg & (~1));
6960         msg_conv.is_owned = false;
6961         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6962         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6963         return (uint64_t)ret_conv;
6964 }
6965
6966 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6967         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6968         LDKChannelUpdate msg_conv;
6969         msg_conv.inner = (void*)(msg & (~1));
6970         msg_conv.is_owned = false;
6971         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6972         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6973         return (uint64_t)ret_conv;
6974 }
6975
6976 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6977         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6978         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6979         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6980         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6981         for (size_t h = 0; h < ret_var.datalen; h++) {
6982                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6983                 *ret_conv_59_conv = ret_var.data[h];
6984                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
6985         }
6986         FREE(ret_var.data);
6987         return ret_arr;
6988 }
6989
6990 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6991         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6992         LDKPublicKey starting_point_ref;
6993         CHECK(*((uint32_t*)starting_point) == 33);
6994         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6995         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6996         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6997         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6998         for (size_t s = 0; s < ret_var.datalen; s++) {
6999                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
7000                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7001                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7002                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
7003                 if (ret_conv_18_var.is_owned) {
7004                         ret_conv_18_ref |= 1;
7005                 }
7006                 ret_arr_ptr[s] = ret_conv_18_ref;
7007         }
7008         FREE(ret_var.data);
7009         return ret_arr;
7010 }
7011
7012 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
7013         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
7014         LDKPublicKey their_node_id_ref;
7015         CHECK(*((uint32_t*)their_node_id) == 33);
7016         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7017         LDKInit init_conv;
7018         init_conv.inner = (void*)(init & (~1));
7019         init_conv.is_owned = false;
7020         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
7021 }
7022
7023 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7024         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
7025         LDKPublicKey their_node_id_ref;
7026         CHECK(*((uint32_t*)their_node_id) == 33);
7027         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7028         LDKReplyChannelRange msg_conv;
7029         msg_conv.inner = (void*)(msg & (~1));
7030         msg_conv.is_owned = (msg & 1) || (msg == 0);
7031         msg_conv = ReplyChannelRange_clone(&msg_conv);
7032         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7033         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7034         return (uint64_t)ret_conv;
7035 }
7036
7037 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) {
7038         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
7039         LDKPublicKey their_node_id_ref;
7040         CHECK(*((uint32_t*)their_node_id) == 33);
7041         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7042         LDKReplyShortChannelIdsEnd msg_conv;
7043         msg_conv.inner = (void*)(msg & (~1));
7044         msg_conv.is_owned = (msg & 1) || (msg == 0);
7045         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
7046         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7047         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7048         return (uint64_t)ret_conv;
7049 }
7050
7051 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7052         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
7053         LDKPublicKey their_node_id_ref;
7054         CHECK(*((uint32_t*)their_node_id) == 33);
7055         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7056         LDKQueryChannelRange msg_conv;
7057         msg_conv.inner = (void*)(msg & (~1));
7058         msg_conv.is_owned = (msg & 1) || (msg == 0);
7059         msg_conv = QueryChannelRange_clone(&msg_conv);
7060         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7061         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7062         return (uint64_t)ret_conv;
7063 }
7064
7065 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7066         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
7067         LDKPublicKey their_node_id_ref;
7068         CHECK(*((uint32_t*)their_node_id) == 33);
7069         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7070         LDKQueryShortChannelIds msg_conv;
7071         msg_conv.inner = (void*)(msg & (~1));
7072         msg_conv.is_owned = (msg & 1) || (msg == 0);
7073         msg_conv = QueryShortChannelIds_clone(&msg_conv);
7074         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7075         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7076         return (uint64_t)ret_conv;
7077 }
7078
7079 typedef struct LDKCustomMessageReader_JCalls {
7080         atomic_size_t refcnt;
7081         uint32_t read_meth;
7082 } LDKCustomMessageReader_JCalls;
7083 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
7084         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7085         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7086                 js_free(j_calls->read_meth);
7087                 FREE(j_calls);
7088         }
7089 }
7090 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
7091         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7092         LDKu8slice buffer_var = buffer;
7093         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7094         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
7095         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
7096         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1);
7097         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
7098         return ret_conv;
7099 }
7100 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
7101         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
7102         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7103 }
7104 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
7105         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
7106         atomic_init(&calls->refcnt, 1);
7107         //TODO: Assign calls->o from o
7108
7109         LDKCustomMessageReader ret = {
7110                 .this_arg = (void*) calls,
7111                 .read = read_LDKCustomMessageReader_jcall,
7112                 .free = LDKCustomMessageReader_JCalls_free,
7113         };
7114         return ret;
7115 }
7116 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
7117         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
7118         *res_ptr = LDKCustomMessageReader_init(o);
7119         return (long)res_ptr;
7120 }
7121 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
7122         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1);
7123         LDKu8slice buffer_ref;
7124         buffer_ref.datalen = *((uint32_t*)buffer);
7125         buffer_ref.data = (int8_t*)(buffer + 4);
7126         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
7127         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
7128         return (uint64_t)ret_conv;
7129 }
7130
7131 typedef struct LDKCustomMessageHandler_JCalls {
7132         atomic_size_t refcnt;
7133         LDKCustomMessageReader_JCalls* CustomMessageReader;
7134         uint32_t handle_custom_message_meth;
7135         uint32_t get_and_clear_pending_msg_meth;
7136 } LDKCustomMessageHandler_JCalls;
7137 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
7138         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7139         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7140                 js_free(j_calls->handle_custom_message_meth);
7141                 js_free(j_calls->get_and_clear_pending_msg_meth);
7142                 FREE(j_calls);
7143         }
7144 }
7145 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
7146         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7147         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
7148         *msg_ret = msg;
7149         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7150         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
7151         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
7152         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
7153         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
7154         return ret_conv;
7155 }
7156 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
7157         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7158         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
7159         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
7160         ret_constr.datalen = *((uint32_t*)ret);
7161         if (ret_constr.datalen > 0)
7162                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
7163         else
7164                 ret_constr.data = NULL;
7165         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7166         for (size_t z = 0; z < ret_constr.datalen; z++) {
7167                 uint32_t ret_conv_25 = ret_vals[z];
7168                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
7169                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
7170                 ret_constr.data[z] = ret_conv_25_conv;
7171         }
7172         return ret_constr;
7173 }
7174 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
7175         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
7176         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7177         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
7178 }
7179 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
7180         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
7181         atomic_init(&calls->refcnt, 1);
7182         //TODO: Assign calls->o from o
7183
7184         LDKCustomMessageHandler ret = {
7185                 .this_arg = (void*) calls,
7186                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
7187                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
7188                 .free = LDKCustomMessageHandler_JCalls_free,
7189                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
7190         };
7191         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
7192         return ret;
7193 }
7194 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
7195         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
7196         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
7197         return (long)res_ptr;
7198 }
7199 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
7200         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
7201         LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1);
7202         LDKPublicKey sender_node_id_ref;
7203         CHECK(*((uint32_t*)sender_node_id) == 33);
7204         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
7205         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7206         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
7207         return (uint64_t)ret_conv;
7208 }
7209
7210 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
7211         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
7212         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
7213         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7214         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7215         for (size_t z = 0; z < ret_var.datalen; z++) {
7216                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
7217                 *ret_conv_25_conv = ret_var.data[z];
7218                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
7219         }
7220         FREE(ret_var.data);
7221         return ret_arr;
7222 }
7223
7224 typedef struct LDKSocketDescriptor_JCalls {
7225         atomic_size_t refcnt;
7226         uint32_t send_data_meth;
7227         uint32_t disconnect_socket_meth;
7228         uint32_t eq_meth;
7229         uint32_t hash_meth;
7230 } LDKSocketDescriptor_JCalls;
7231 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
7232         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7233         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7234                 js_free(j_calls->send_data_meth);
7235                 js_free(j_calls->disconnect_socket_meth);
7236                 js_free(j_calls->eq_meth);
7237                 js_free(j_calls->hash_meth);
7238                 FREE(j_calls);
7239         }
7240 }
7241 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
7242         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7243         LDKu8slice data_var = data;
7244         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7245         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
7246         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
7247 }
7248 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
7249         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7250         js_invoke_function_0(j_calls->disconnect_socket_meth);
7251 }
7252 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
7253         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7254         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7255         *other_arg_clone = SocketDescriptor_clone(other_arg);
7256         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
7257 }
7258 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
7259         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7260         return js_invoke_function_0(j_calls->hash_meth);
7261 }
7262 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
7263         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
7264         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7265 }
7266 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
7267         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
7268         atomic_init(&calls->refcnt, 1);
7269         //TODO: Assign calls->o from o
7270
7271         LDKSocketDescriptor ret = {
7272                 .this_arg = (void*) calls,
7273                 .send_data = send_data_LDKSocketDescriptor_jcall,
7274                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
7275                 .eq = eq_LDKSocketDescriptor_jcall,
7276                 .hash = hash_LDKSocketDescriptor_jcall,
7277                 .cloned = LDKSocketDescriptor_JCalls_cloned,
7278                 .free = LDKSocketDescriptor_JCalls_free,
7279         };
7280         return ret;
7281 }
7282 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
7283         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7284         *res_ptr = LDKSocketDescriptor_init(o);
7285         return (long)res_ptr;
7286 }
7287 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
7288         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7289         LDKu8slice data_ref;
7290         data_ref.datalen = *((uint32_t*)data);
7291         data_ref.data = (int8_t*)(data + 4);
7292         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
7293         return ret_val;
7294 }
7295
7296 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
7297         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7298         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
7299 }
7300
7301 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
7302         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7303         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
7304         return ret_val;
7305 }
7306
7307 typedef struct LDKScore_JCalls {
7308         atomic_size_t refcnt;
7309         uint32_t channel_penalty_msat_meth;
7310 } LDKScore_JCalls;
7311 static void LDKScore_JCalls_free(void* this_arg) {
7312         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7313         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7314                 js_free(j_calls->channel_penalty_msat_meth);
7315                 FREE(j_calls);
7316         }
7317 }
7318 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id) {
7319         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7320         return js_invoke_function_1(j_calls->channel_penalty_msat_meth, short_channel_id);
7321 }
7322 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
7323         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
7324         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7325 }
7326 static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
7327         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
7328         atomic_init(&calls->refcnt, 1);
7329         //TODO: Assign calls->o from o
7330
7331         LDKScore ret = {
7332                 .this_arg = (void*) calls,
7333                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
7334                 .free = LDKScore_JCalls_free,
7335         };
7336         return ret;
7337 }
7338 long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object Reference */void* o) {
7339         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
7340         *res_ptr = LDKScore_init(o);
7341         return (long)res_ptr;
7342 }
7343 int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id) {
7344         LDKScore* this_arg_conv = (LDKScore*)(((uint64_t)this_arg) & ~1);
7345         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id);
7346         return ret_val;
7347 }
7348
7349 typedef struct LDKChannelManagerPersister_JCalls {
7350         atomic_size_t refcnt;
7351         uint32_t persist_manager_meth;
7352 } LDKChannelManagerPersister_JCalls;
7353 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
7354         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7355         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7356                 js_free(j_calls->persist_manager_meth);
7357                 FREE(j_calls);
7358         }
7359 }
7360 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
7361         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7362         LDKChannelManager channel_manager_var = *channel_manager;
7363         // Warning: we may need a move here but no clone is available for LDKChannelManager
7364         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7365         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7366         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
7367         if (channel_manager_var.is_owned) {
7368                 channel_manager_ref |= 1;
7369         }
7370         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
7371         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
7372         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
7373         return ret_conv;
7374 }
7375 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
7376         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
7377         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7378 }
7379 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
7380         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
7381         atomic_init(&calls->refcnt, 1);
7382         //TODO: Assign calls->o from o
7383
7384         LDKChannelManagerPersister ret = {
7385                 .this_arg = (void*) calls,
7386                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
7387                 .free = LDKChannelManagerPersister_JCalls_free,
7388         };
7389         return ret;
7390 }
7391 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
7392         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
7393         *res_ptr = LDKChannelManagerPersister_init(o);
7394         return (long)res_ptr;
7395 }
7396 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
7397         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
7398         LDKChannelManager channel_manager_conv;
7399         channel_manager_conv.inner = (void*)(channel_manager & (~1));
7400         channel_manager_conv.is_owned = false;
7401         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7402         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
7403         return (uint64_t)ret_conv;
7404 }
7405
7406 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
7407         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
7408         switch(obj->tag) {
7409                 case LDKFallback_SegWitProgram: {
7410                         uint8_t version_val = obj->seg_wit_program.version._0;
7411                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
7412                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7413                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
7414                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
7415                 }
7416                 case LDKFallback_PubKeyHash: {
7417                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7418                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
7419                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
7420                 }
7421                 case LDKFallback_ScriptHash: {
7422                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7423                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
7424                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
7425                 }
7426                 default: abort();
7427         }
7428 }
7429 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
7430         LDKStr ret_str = _ldk_get_compiled_version();
7431         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7432         Str_free(ret_str);
7433         return ret_conv;
7434 }
7435
7436 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
7437         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
7438         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7439         Str_free(ret_str);
7440         return ret_conv;
7441 }
7442
7443 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
7444         LDKTransaction _res_ref;
7445         _res_ref.datalen = *((uint32_t*)_res);
7446         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
7447         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7448         _res_ref.data_is_owned = true;
7449         Transaction_free(_res_ref);
7450 }
7451
7452 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
7453         LDKCVec_u8Z script_pubkey_ref;
7454         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
7455         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
7456         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
7457         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7458         *ret_ref = TxOut_new(script_pubkey_ref, value);
7459         return (uint64_t)ret_ref;
7460 }
7461
7462 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
7463         if ((_res & 1) != 0) return;
7464         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
7465         FREE((void*)_res);
7466         TxOut_free(_res_conv);
7467 }
7468
7469 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
7470         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
7471         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7472         *ret_ref = TxOut_clone(orig_conv);
7473         return (uint64_t)ret_ref;
7474 }
7475
7476 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
7477         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
7478         Str_free(dummy);
7479 }
7480
7481 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
7482         LDKSecretKey o_ref;
7483         CHECK(*((uint32_t*)o) == 32);
7484         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
7485         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7486         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
7487         return (uint64_t)ret_conv;
7488 }
7489
7490 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
7491         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7492         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7493         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
7494         return (uint64_t)ret_conv;
7495 }
7496
7497 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
7498         if ((_res & 1) != 0) return;
7499         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
7500         FREE((void*)_res);
7501         CResult_SecretKeyErrorZ_free(_res_conv);
7502 }
7503
7504 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
7505         LDKPublicKey o_ref;
7506         CHECK(*((uint32_t*)o) == 33);
7507         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
7508         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7509         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
7510         return (uint64_t)ret_conv;
7511 }
7512
7513 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
7514         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7515         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7516         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
7517         return (uint64_t)ret_conv;
7518 }
7519
7520 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
7521         if ((_res & 1) != 0) return;
7522         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
7523         FREE((void*)_res);
7524         CResult_PublicKeyErrorZ_free(_res_conv);
7525 }
7526
7527 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
7528         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
7529         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7530         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
7531         return (uint64_t)ret_conv;
7532 }
7533
7534 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
7535         LDKTxCreationKeys o_conv;
7536         o_conv.inner = (void*)(o & (~1));
7537         o_conv.is_owned = (o & 1) || (o == 0);
7538         o_conv = TxCreationKeys_clone(&o_conv);
7539         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7540         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
7541         return (uint64_t)ret_conv;
7542 }
7543
7544 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
7545         LDKDecodeError e_conv;
7546         e_conv.inner = (void*)(e & (~1));
7547         e_conv.is_owned = (e & 1) || (e == 0);
7548         e_conv = DecodeError_clone(&e_conv);
7549         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7550         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
7551         return (uint64_t)ret_conv;
7552 }
7553
7554 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
7555         if ((_res & 1) != 0) return;
7556         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7557         FREE((void*)_res);
7558         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
7559 }
7560
7561 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
7562         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
7563         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7564         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
7565         return (uint64_t)ret_conv;
7566 }
7567
7568 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
7569         LDKChannelPublicKeys o_conv;
7570         o_conv.inner = (void*)(o & (~1));
7571         o_conv.is_owned = (o & 1) || (o == 0);
7572         o_conv = ChannelPublicKeys_clone(&o_conv);
7573         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7574         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
7575         return (uint64_t)ret_conv;
7576 }
7577
7578 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
7579         LDKDecodeError e_conv;
7580         e_conv.inner = (void*)(e & (~1));
7581         e_conv.is_owned = (e & 1) || (e == 0);
7582         e_conv = DecodeError_clone(&e_conv);
7583         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7584         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
7585         return (uint64_t)ret_conv;
7586 }
7587
7588 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
7589         if ((_res & 1) != 0) return;
7590         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7591         FREE((void*)_res);
7592         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
7593 }
7594
7595 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
7596         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
7597         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7598         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
7599         return (uint64_t)ret_conv;
7600 }
7601
7602 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
7603         LDKTxCreationKeys o_conv;
7604         o_conv.inner = (void*)(o & (~1));
7605         o_conv.is_owned = (o & 1) || (o == 0);
7606         o_conv = TxCreationKeys_clone(&o_conv);
7607         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7608         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
7609         return (uint64_t)ret_conv;
7610 }
7611
7612 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
7613         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7614         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7615         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
7616         return (uint64_t)ret_conv;
7617 }
7618
7619 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
7620         if ((_res & 1) != 0) return;
7621         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
7622         FREE((void*)_res);
7623         CResult_TxCreationKeysErrorZ_free(_res_conv);
7624 }
7625
7626 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
7627         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
7628         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7629         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
7630         return (uint64_t)ret_conv;
7631 }
7632
7633 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
7634         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7635         *ret_copy = COption_u32Z_some(o);
7636         uint64_t ret_ref = (uint64_t)ret_copy;
7637         return ret_ref;
7638 }
7639
7640 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
7641         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7642         *ret_copy = COption_u32Z_none();
7643         uint64_t ret_ref = (uint64_t)ret_copy;
7644         return ret_ref;
7645 }
7646
7647 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
7648         if ((_res & 1) != 0) return;
7649         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
7650         FREE((void*)_res);
7651         COption_u32Z_free(_res_conv);
7652 }
7653
7654 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
7655         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
7656         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7657         *ret_copy = COption_u32Z_clone(orig_conv);
7658         uint64_t ret_ref = (uint64_t)ret_copy;
7659         return ret_ref;
7660 }
7661
7662 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
7663         LDKHTLCOutputInCommitment o_conv;
7664         o_conv.inner = (void*)(o & (~1));
7665         o_conv.is_owned = (o & 1) || (o == 0);
7666         o_conv = HTLCOutputInCommitment_clone(&o_conv);
7667         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7668         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
7669         return (uint64_t)ret_conv;
7670 }
7671
7672 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
7673         LDKDecodeError e_conv;
7674         e_conv.inner = (void*)(e & (~1));
7675         e_conv.is_owned = (e & 1) || (e == 0);
7676         e_conv = DecodeError_clone(&e_conv);
7677         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7678         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
7679         return (uint64_t)ret_conv;
7680 }
7681
7682 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
7683         if ((_res & 1) != 0) return;
7684         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
7685         FREE((void*)_res);
7686         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
7687 }
7688
7689 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
7690         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
7691         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7692         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
7693         return (uint64_t)ret_conv;
7694 }
7695
7696 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7697         LDKCounterpartyChannelTransactionParameters o_conv;
7698         o_conv.inner = (void*)(o & (~1));
7699         o_conv.is_owned = (o & 1) || (o == 0);
7700         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
7701         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7702         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7703         return (uint64_t)ret_conv;
7704 }
7705
7706 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7707         LDKDecodeError e_conv;
7708         e_conv.inner = (void*)(e & (~1));
7709         e_conv.is_owned = (e & 1) || (e == 0);
7710         e_conv = DecodeError_clone(&e_conv);
7711         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7712         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
7713         return (uint64_t)ret_conv;
7714 }
7715
7716 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7717         if ((_res & 1) != 0) return;
7718         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7719         FREE((void*)_res);
7720         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7721 }
7722
7723 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7724         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7725         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7726         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7727         return (uint64_t)ret_conv;
7728 }
7729
7730 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7731         LDKChannelTransactionParameters o_conv;
7732         o_conv.inner = (void*)(o & (~1));
7733         o_conv.is_owned = (o & 1) || (o == 0);
7734         o_conv = ChannelTransactionParameters_clone(&o_conv);
7735         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7736         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7737         return (uint64_t)ret_conv;
7738 }
7739
7740 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7741         LDKDecodeError e_conv;
7742         e_conv.inner = (void*)(e & (~1));
7743         e_conv.is_owned = (e & 1) || (e == 0);
7744         e_conv = DecodeError_clone(&e_conv);
7745         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7746         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
7747         return (uint64_t)ret_conv;
7748 }
7749
7750 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7751         if ((_res & 1) != 0) return;
7752         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7753         FREE((void*)_res);
7754         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7755 }
7756
7757 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7758         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7759         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7760         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7761         return (uint64_t)ret_conv;
7762 }
7763
7764 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
7765         LDKCVec_SignatureZ _res_constr;
7766         _res_constr.datalen = *((uint32_t*)_res);
7767         if (_res_constr.datalen > 0)
7768                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7769         else
7770                 _res_constr.data = NULL;
7771         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7772         for (size_t m = 0; m < _res_constr.datalen; m++) {
7773                 int8_tArray _res_conv_12 = _res_vals[m];
7774                 LDKSignature _res_conv_12_ref;
7775                 CHECK(*((uint32_t*)_res_conv_12) == 64);
7776                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
7777                 _res_constr.data[m] = _res_conv_12_ref;
7778         }
7779         CVec_SignatureZ_free(_res_constr);
7780 }
7781
7782 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7783         LDKHolderCommitmentTransaction o_conv;
7784         o_conv.inner = (void*)(o & (~1));
7785         o_conv.is_owned = (o & 1) || (o == 0);
7786         o_conv = HolderCommitmentTransaction_clone(&o_conv);
7787         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7788         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
7789         return (uint64_t)ret_conv;
7790 }
7791
7792 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7793         LDKDecodeError e_conv;
7794         e_conv.inner = (void*)(e & (~1));
7795         e_conv.is_owned = (e & 1) || (e == 0);
7796         e_conv = DecodeError_clone(&e_conv);
7797         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7798         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
7799         return (uint64_t)ret_conv;
7800 }
7801
7802 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7803         if ((_res & 1) != 0) return;
7804         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7805         FREE((void*)_res);
7806         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
7807 }
7808
7809 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7810         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7811         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7812         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7813         return (uint64_t)ret_conv;
7814 }
7815
7816 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7817         LDKBuiltCommitmentTransaction o_conv;
7818         o_conv.inner = (void*)(o & (~1));
7819         o_conv.is_owned = (o & 1) || (o == 0);
7820         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
7821         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7822         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
7823         return (uint64_t)ret_conv;
7824 }
7825
7826 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7827         LDKDecodeError e_conv;
7828         e_conv.inner = (void*)(e & (~1));
7829         e_conv.is_owned = (e & 1) || (e == 0);
7830         e_conv = DecodeError_clone(&e_conv);
7831         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7832         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
7833         return (uint64_t)ret_conv;
7834 }
7835
7836 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7837         if ((_res & 1) != 0) return;
7838         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7839         FREE((void*)_res);
7840         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
7841 }
7842
7843 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7844         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7845         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7846         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7847         return (uint64_t)ret_conv;
7848 }
7849
7850 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
7851         LDKTrustedClosingTransaction o_conv;
7852         o_conv.inner = (void*)(o & (~1));
7853         o_conv.is_owned = (o & 1) || (o == 0);
7854         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
7855         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7856         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
7857         return (uint64_t)ret_conv;
7858 }
7859
7860 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
7861         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7862         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
7863         return (uint64_t)ret_conv;
7864 }
7865
7866 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
7867         if ((_res & 1) != 0) return;
7868         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1);
7869         FREE((void*)_res);
7870         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
7871 }
7872
7873 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7874         LDKCommitmentTransaction o_conv;
7875         o_conv.inner = (void*)(o & (~1));
7876         o_conv.is_owned = (o & 1) || (o == 0);
7877         o_conv = CommitmentTransaction_clone(&o_conv);
7878         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7879         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
7880         return (uint64_t)ret_conv;
7881 }
7882
7883 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7884         LDKDecodeError e_conv;
7885         e_conv.inner = (void*)(e & (~1));
7886         e_conv.is_owned = (e & 1) || (e == 0);
7887         e_conv = DecodeError_clone(&e_conv);
7888         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7889         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
7890         return (uint64_t)ret_conv;
7891 }
7892
7893 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7894         if ((_res & 1) != 0) return;
7895         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7896         FREE((void*)_res);
7897         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
7898 }
7899
7900 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7901         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
7902         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7903         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
7904         return (uint64_t)ret_conv;
7905 }
7906
7907 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
7908         LDKTrustedCommitmentTransaction o_conv;
7909         o_conv.inner = (void*)(o & (~1));
7910         o_conv.is_owned = (o & 1) || (o == 0);
7911         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
7912         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7913         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
7914         return (uint64_t)ret_conv;
7915 }
7916
7917 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
7918         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7919         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
7920         return (uint64_t)ret_conv;
7921 }
7922
7923 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
7924         if ((_res & 1) != 0) return;
7925         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7926         FREE((void*)_res);
7927         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7928 }
7929
7930 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
7931         LDKCVec_SignatureZ o_constr;
7932         o_constr.datalen = *((uint32_t*)o);
7933         if (o_constr.datalen > 0)
7934                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7935         else
7936                 o_constr.data = NULL;
7937         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7938         for (size_t m = 0; m < o_constr.datalen; m++) {
7939                 int8_tArray o_conv_12 = o_vals[m];
7940                 LDKSignature o_conv_12_ref;
7941                 CHECK(*((uint32_t*)o_conv_12) == 64);
7942                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
7943                 o_constr.data[m] = o_conv_12_ref;
7944         }
7945         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7946         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7947         return (uint64_t)ret_conv;
7948 }
7949
7950 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
7951         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7952         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7953         return (uint64_t)ret_conv;
7954 }
7955
7956 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
7957         if ((_res & 1) != 0) return;
7958         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7959         FREE((void*)_res);
7960         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7961 }
7962
7963 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
7964         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7965         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7966         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7967         return (uint64_t)ret_conv;
7968 }
7969
7970 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
7971         LDKShutdownScript o_conv;
7972         o_conv.inner = (void*)(o & (~1));
7973         o_conv.is_owned = (o & 1) || (o == 0);
7974         o_conv = ShutdownScript_clone(&o_conv);
7975         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7976         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
7977         return (uint64_t)ret_conv;
7978 }
7979
7980 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
7981         LDKDecodeError e_conv;
7982         e_conv.inner = (void*)(e & (~1));
7983         e_conv.is_owned = (e & 1) || (e == 0);
7984         e_conv = DecodeError_clone(&e_conv);
7985         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7986         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
7987         return (uint64_t)ret_conv;
7988 }
7989
7990 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
7991         if ((_res & 1) != 0) return;
7992         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
7993         FREE((void*)_res);
7994         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
7995 }
7996
7997 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
7998         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
7999         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8000         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
8001         return (uint64_t)ret_conv;
8002 }
8003
8004 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
8005         LDKShutdownScript o_conv;
8006         o_conv.inner = (void*)(o & (~1));
8007         o_conv.is_owned = (o & 1) || (o == 0);
8008         o_conv = ShutdownScript_clone(&o_conv);
8009         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8010         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
8011         return (uint64_t)ret_conv;
8012 }
8013
8014 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
8015         LDKInvalidShutdownScript e_conv;
8016         e_conv.inner = (void*)(e & (~1));
8017         e_conv.is_owned = (e & 1) || (e == 0);
8018         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
8019         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8020         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
8021         return (uint64_t)ret_conv;
8022 }
8023
8024 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
8025         if ((_res & 1) != 0) return;
8026         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
8027         FREE((void*)_res);
8028         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
8029 }
8030
8031 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
8032         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8033         *ret_conv = CResult_NoneErrorZ_ok();
8034         return (uint64_t)ret_conv;
8035 }
8036
8037 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
8038         LDKIOError e_conv = LDKIOError_from_js(e);
8039         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8040         *ret_conv = CResult_NoneErrorZ_err(e_conv);
8041         return (uint64_t)ret_conv;
8042 }
8043
8044 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
8045         if ((_res & 1) != 0) return;
8046         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
8047         FREE((void*)_res);
8048         CResult_NoneErrorZ_free(_res_conv);
8049 }
8050
8051 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
8052         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
8053         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8054         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
8055         return (uint64_t)ret_conv;
8056 }
8057
8058 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
8059         LDKRouteHop o_conv;
8060         o_conv.inner = (void*)(o & (~1));
8061         o_conv.is_owned = (o & 1) || (o == 0);
8062         o_conv = RouteHop_clone(&o_conv);
8063         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8064         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
8065         return (uint64_t)ret_conv;
8066 }
8067
8068 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
8069         LDKDecodeError e_conv;
8070         e_conv.inner = (void*)(e & (~1));
8071         e_conv.is_owned = (e & 1) || (e == 0);
8072         e_conv = DecodeError_clone(&e_conv);
8073         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8074         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
8075         return (uint64_t)ret_conv;
8076 }
8077
8078 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
8079         if ((_res & 1) != 0) return;
8080         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
8081         FREE((void*)_res);
8082         CResult_RouteHopDecodeErrorZ_free(_res_conv);
8083 }
8084
8085 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
8086         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
8087         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8088         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
8089         return (uint64_t)ret_conv;
8090 }
8091
8092 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
8093         LDKCVec_RouteHopZ _res_constr;
8094         _res_constr.datalen = *((uint32_t*)_res);
8095         if (_res_constr.datalen > 0)
8096                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8097         else
8098                 _res_constr.data = NULL;
8099         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8100         for (size_t k = 0; k < _res_constr.datalen; k++) {
8101                 uint32_t _res_conv_10 = _res_vals[k];
8102                 LDKRouteHop _res_conv_10_conv;
8103                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
8104                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
8105                 _res_constr.data[k] = _res_conv_10_conv;
8106         }
8107         CVec_RouteHopZ_free(_res_constr);
8108 }
8109
8110 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
8111         LDKCVec_CVec_RouteHopZZ _res_constr;
8112         _res_constr.datalen = *((uint32_t*)_res);
8113         if (_res_constr.datalen > 0)
8114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
8115         else
8116                 _res_constr.data = NULL;
8117         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
8118         for (size_t m = 0; m < _res_constr.datalen; m++) {
8119                 uint32_tArray _res_conv_12 = _res_vals[m];
8120                 LDKCVec_RouteHopZ _res_conv_12_constr;
8121                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
8122                 if (_res_conv_12_constr.datalen > 0)
8123                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8124                 else
8125                         _res_conv_12_constr.data = NULL;
8126                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
8127                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
8128                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
8129                         LDKRouteHop _res_conv_12_conv_10_conv;
8130                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
8131                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
8132                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
8133                 }
8134                 _res_constr.data[m] = _res_conv_12_constr;
8135         }
8136         CVec_CVec_RouteHopZZ_free(_res_constr);
8137 }
8138
8139 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
8140         LDKRoute o_conv;
8141         o_conv.inner = (void*)(o & (~1));
8142         o_conv.is_owned = (o & 1) || (o == 0);
8143         o_conv = Route_clone(&o_conv);
8144         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8145         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
8146         return (uint64_t)ret_conv;
8147 }
8148
8149 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
8150         LDKDecodeError e_conv;
8151         e_conv.inner = (void*)(e & (~1));
8152         e_conv.is_owned = (e & 1) || (e == 0);
8153         e_conv = DecodeError_clone(&e_conv);
8154         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8155         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
8156         return (uint64_t)ret_conv;
8157 }
8158
8159 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
8160         if ((_res & 1) != 0) return;
8161         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
8162         FREE((void*)_res);
8163         CResult_RouteDecodeErrorZ_free(_res_conv);
8164 }
8165
8166 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
8167         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
8168         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8169         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
8170         return (uint64_t)ret_conv;
8171 }
8172
8173 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
8174         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8175         *ret_copy = COption_u64Z_some(o);
8176         uint64_t ret_ref = (uint64_t)ret_copy;
8177         return ret_ref;
8178 }
8179
8180 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
8181         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8182         *ret_copy = COption_u64Z_none();
8183         uint64_t ret_ref = (uint64_t)ret_copy;
8184         return ret_ref;
8185 }
8186
8187 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
8188         if ((_res & 1) != 0) return;
8189         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
8190         FREE((void*)_res);
8191         COption_u64Z_free(_res_conv);
8192 }
8193
8194 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
8195         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
8196         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8197         *ret_copy = COption_u64Z_clone(orig_conv);
8198         uint64_t ret_ref = (uint64_t)ret_copy;
8199         return ret_ref;
8200 }
8201
8202 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
8203         LDKCVec_ChannelDetailsZ _res_constr;
8204         _res_constr.datalen = *((uint32_t*)_res);
8205         if (_res_constr.datalen > 0)
8206                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8207         else
8208                 _res_constr.data = NULL;
8209         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8210         for (size_t q = 0; q < _res_constr.datalen; q++) {
8211                 uint32_t _res_conv_16 = _res_vals[q];
8212                 LDKChannelDetails _res_conv_16_conv;
8213                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
8214                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
8215                 _res_constr.data[q] = _res_conv_16_conv;
8216         }
8217         CVec_ChannelDetailsZ_free(_res_constr);
8218 }
8219
8220 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
8221         LDKCVec_RouteHintZ _res_constr;
8222         _res_constr.datalen = *((uint32_t*)_res);
8223         if (_res_constr.datalen > 0)
8224                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
8225         else
8226                 _res_constr.data = NULL;
8227         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8228         for (size_t l = 0; l < _res_constr.datalen; l++) {
8229                 uint32_t _res_conv_11 = _res_vals[l];
8230                 LDKRouteHint _res_conv_11_conv;
8231                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
8232                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
8233                 _res_constr.data[l] = _res_conv_11_conv;
8234         }
8235         CVec_RouteHintZ_free(_res_constr);
8236 }
8237
8238 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
8239         LDKRoute o_conv;
8240         o_conv.inner = (void*)(o & (~1));
8241         o_conv.is_owned = (o & 1) || (o == 0);
8242         o_conv = Route_clone(&o_conv);
8243         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8244         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
8245         return (uint64_t)ret_conv;
8246 }
8247
8248 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
8249         LDKLightningError e_conv;
8250         e_conv.inner = (void*)(e & (~1));
8251         e_conv.is_owned = (e & 1) || (e == 0);
8252         e_conv = LightningError_clone(&e_conv);
8253         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8254         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
8255         return (uint64_t)ret_conv;
8256 }
8257
8258 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
8259         if ((_res & 1) != 0) return;
8260         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
8261         FREE((void*)_res);
8262         CResult_RouteLightningErrorZ_free(_res_conv);
8263 }
8264
8265 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
8266         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
8267         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8268         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
8269         return (uint64_t)ret_conv;
8270 }
8271
8272 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
8273         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
8274         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
8275         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8276         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
8277         return (uint64_t)ret_conv;
8278 }
8279
8280 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
8281         LDKAccessError e_conv = LDKAccessError_from_js(e);
8282         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8283         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
8284         return (uint64_t)ret_conv;
8285 }
8286
8287 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
8288         if ((_res & 1) != 0) return;
8289         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
8290         FREE((void*)_res);
8291         CResult_TxOutAccessErrorZ_free(_res_conv);
8292 }
8293
8294 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
8295         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
8296         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8297         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
8298         return (uint64_t)ret_conv;
8299 }
8300
8301 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
8302         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
8303         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8304         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
8305         return ((uint64_t)ret_conv);
8306 }
8307
8308 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
8309         LDKTransaction b_ref;
8310         b_ref.datalen = *((uint32_t*)b);
8311         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
8312         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8313         b_ref.data_is_owned = true;
8314         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8315         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
8316         return ((uint64_t)ret_conv);
8317 }
8318
8319 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
8320         if ((_res & 1) != 0) return;
8321         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
8322         FREE((void*)_res);
8323         C2Tuple_usizeTransactionZ_free(_res_conv);
8324 }
8325
8326 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
8327         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
8328         _res_constr.datalen = *((uint32_t*)_res);
8329         if (_res_constr.datalen > 0)
8330                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8331         else
8332                 _res_constr.data = NULL;
8333         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8334         for (size_t c = 0; c < _res_constr.datalen; c++) {
8335                 uint32_t _res_conv_28 = _res_vals[c];
8336                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
8337                 FREE((void*)_res_conv_28);
8338                 _res_constr.data[c] = _res_conv_28_conv;
8339         }
8340         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
8341 }
8342
8343 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
8344         LDKCVec_TxidZ _res_constr;
8345         _res_constr.datalen = *((uint32_t*)_res);
8346         if (_res_constr.datalen > 0)
8347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8348         else
8349                 _res_constr.data = NULL;
8350         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8351         for (size_t m = 0; m < _res_constr.datalen; m++) {
8352                 int8_tArray _res_conv_12 = _res_vals[m];
8353                 LDKThirtyTwoBytes _res_conv_12_ref;
8354                 CHECK(*((uint32_t*)_res_conv_12) == 32);
8355                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
8356                 _res_constr.data[m] = _res_conv_12_ref;
8357         }
8358         CVec_TxidZ_free(_res_constr);
8359 }
8360
8361 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
8362         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8363         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
8364         return (uint64_t)ret_conv;
8365 }
8366
8367 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
8368         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
8369         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8370         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
8371         return (uint64_t)ret_conv;
8372 }
8373
8374 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
8375         if ((_res & 1) != 0) return;
8376         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
8377         FREE((void*)_res);
8378         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
8379 }
8380
8381 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
8382         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
8383         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8384         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
8385         return (uint64_t)ret_conv;
8386 }
8387
8388 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
8389         LDKCVec_MonitorEventZ _res_constr;
8390         _res_constr.datalen = *((uint32_t*)_res);
8391         if (_res_constr.datalen > 0)
8392                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
8393         else
8394                 _res_constr.data = NULL;
8395         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8396         for (size_t o = 0; o < _res_constr.datalen; o++) {
8397                 uint32_t _res_conv_14 = _res_vals[o];
8398                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
8399                 FREE((void*)_res_conv_14);
8400                 _res_constr.data[o] = _res_conv_14_conv;
8401         }
8402         CVec_MonitorEventZ_free(_res_constr);
8403 }
8404
8405 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
8406         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8407         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
8408         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8409         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8410         uint64_t ret_ref = (uint64_t)ret_copy;
8411         return ret_ref;
8412 }
8413
8414 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
8415         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8416         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8417         uint64_t ret_ref = (uint64_t)ret_copy;
8418         return ret_ref;
8419 }
8420
8421 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
8422         if ((_res & 1) != 0) return;
8423         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8424         FREE((void*)_res);
8425         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8426 }
8427
8428 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
8429         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
8430         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8431         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
8432         uint64_t ret_ref = (uint64_t)ret_copy;
8433         return ret_ref;
8434 }
8435
8436 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
8437         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
8438         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
8439         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8440         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
8441         uint64_t ret_ref = (uint64_t)ret_copy;
8442         return ret_ref;
8443 }
8444
8445 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
8446         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8447         *ret_copy = COption_NetworkUpdateZ_none();
8448         uint64_t ret_ref = (uint64_t)ret_copy;
8449         return ret_ref;
8450 }
8451
8452 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
8453         if ((_res & 1) != 0) return;
8454         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1);
8455         FREE((void*)_res);
8456         COption_NetworkUpdateZ_free(_res_conv);
8457 }
8458
8459 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
8460         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
8461         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8462         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
8463         uint64_t ret_ref = (uint64_t)ret_copy;
8464         return ret_ref;
8465 }
8466
8467 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
8468         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8469         _res_constr.datalen = *((uint32_t*)_res);
8470         if (_res_constr.datalen > 0)
8471                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8472         else
8473                 _res_constr.data = NULL;
8474         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8475         for (size_t b = 0; b < _res_constr.datalen; b++) {
8476                 uint32_t _res_conv_27 = _res_vals[b];
8477                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8478                 FREE((void*)_res_conv_27);
8479                 _res_constr.data[b] = _res_conv_27_conv;
8480         }
8481         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8482 }
8483
8484 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
8485         LDKCVec_MessageSendEventZ _res_constr;
8486         _res_constr.datalen = *((uint32_t*)_res);
8487         if (_res_constr.datalen > 0)
8488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8489         else
8490                 _res_constr.data = NULL;
8491         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8492         for (size_t s = 0; s < _res_constr.datalen; s++) {
8493                 uint32_t _res_conv_18 = _res_vals[s];
8494                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
8495                 FREE((void*)_res_conv_18);
8496                 _res_constr.data[s] = _res_conv_18_conv;
8497         }
8498         CVec_MessageSendEventZ_free(_res_constr);
8499 }
8500
8501 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
8502         LDKInitFeatures o_conv;
8503         o_conv.inner = (void*)(o & (~1));
8504         o_conv.is_owned = (o & 1) || (o == 0);
8505         o_conv = InitFeatures_clone(&o_conv);
8506         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8507         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
8508         return (uint64_t)ret_conv;
8509 }
8510
8511 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
8512         LDKDecodeError e_conv;
8513         e_conv.inner = (void*)(e & (~1));
8514         e_conv.is_owned = (e & 1) || (e == 0);
8515         e_conv = DecodeError_clone(&e_conv);
8516         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8517         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
8518         return (uint64_t)ret_conv;
8519 }
8520
8521 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
8522         if ((_res & 1) != 0) return;
8523         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8524         FREE((void*)_res);
8525         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
8526 }
8527
8528 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
8529         LDKNodeFeatures o_conv;
8530         o_conv.inner = (void*)(o & (~1));
8531         o_conv.is_owned = (o & 1) || (o == 0);
8532         o_conv = NodeFeatures_clone(&o_conv);
8533         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8534         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
8535         return (uint64_t)ret_conv;
8536 }
8537
8538 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
8539         LDKDecodeError e_conv;
8540         e_conv.inner = (void*)(e & (~1));
8541         e_conv.is_owned = (e & 1) || (e == 0);
8542         e_conv = DecodeError_clone(&e_conv);
8543         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8544         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
8545         return (uint64_t)ret_conv;
8546 }
8547
8548 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
8549         if ((_res & 1) != 0) return;
8550         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8551         FREE((void*)_res);
8552         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
8553 }
8554
8555 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
8556         LDKChannelFeatures o_conv;
8557         o_conv.inner = (void*)(o & (~1));
8558         o_conv.is_owned = (o & 1) || (o == 0);
8559         o_conv = ChannelFeatures_clone(&o_conv);
8560         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8561         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
8562         return (uint64_t)ret_conv;
8563 }
8564
8565 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
8566         LDKDecodeError e_conv;
8567         e_conv.inner = (void*)(e & (~1));
8568         e_conv.is_owned = (e & 1) || (e == 0);
8569         e_conv = DecodeError_clone(&e_conv);
8570         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8571         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
8572         return (uint64_t)ret_conv;
8573 }
8574
8575 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
8576         if ((_res & 1) != 0) return;
8577         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8578         FREE((void*)_res);
8579         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
8580 }
8581
8582 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
8583         LDKInvoiceFeatures o_conv;
8584         o_conv.inner = (void*)(o & (~1));
8585         o_conv.is_owned = (o & 1) || (o == 0);
8586         o_conv = InvoiceFeatures_clone(&o_conv);
8587         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8588         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
8589         return (uint64_t)ret_conv;
8590 }
8591
8592 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
8593         LDKDecodeError e_conv;
8594         e_conv.inner = (void*)(e & (~1));
8595         e_conv.is_owned = (e & 1) || (e == 0);
8596         e_conv = DecodeError_clone(&e_conv);
8597         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8598         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
8599         return (uint64_t)ret_conv;
8600 }
8601
8602 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
8603         if ((_res & 1) != 0) return;
8604         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8605         FREE((void*)_res);
8606         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8610         LDKDelayedPaymentOutputDescriptor o_conv;
8611         o_conv.inner = (void*)(o & (~1));
8612         o_conv.is_owned = (o & 1) || (o == 0);
8613         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
8614         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8615         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8616         return (uint64_t)ret_conv;
8617 }
8618
8619 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8620         LDKDecodeError e_conv;
8621         e_conv.inner = (void*)(e & (~1));
8622         e_conv.is_owned = (e & 1) || (e == 0);
8623         e_conv = DecodeError_clone(&e_conv);
8624         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8625         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8626         return (uint64_t)ret_conv;
8627 }
8628
8629 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8630         if ((_res & 1) != 0) return;
8631         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8632         FREE((void*)_res);
8633         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8634 }
8635
8636 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8637         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8638         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8639         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8640         return (uint64_t)ret_conv;
8641 }
8642
8643 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8644         LDKStaticPaymentOutputDescriptor o_conv;
8645         o_conv.inner = (void*)(o & (~1));
8646         o_conv.is_owned = (o & 1) || (o == 0);
8647         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
8648         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8649         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8650         return (uint64_t)ret_conv;
8651 }
8652
8653 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8654         LDKDecodeError e_conv;
8655         e_conv.inner = (void*)(e & (~1));
8656         e_conv.is_owned = (e & 1) || (e == 0);
8657         e_conv = DecodeError_clone(&e_conv);
8658         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8659         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8660         return (uint64_t)ret_conv;
8661 }
8662
8663 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8664         if ((_res & 1) != 0) return;
8665         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8666         FREE((void*)_res);
8667         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8668 }
8669
8670 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8671         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8672         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8673         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8674         return (uint64_t)ret_conv;
8675 }
8676
8677 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8678         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8679         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
8680         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8681         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8682         return (uint64_t)ret_conv;
8683 }
8684
8685 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8686         LDKDecodeError e_conv;
8687         e_conv.inner = (void*)(e & (~1));
8688         e_conv.is_owned = (e & 1) || (e == 0);
8689         e_conv = DecodeError_clone(&e_conv);
8690         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8691         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8692         return (uint64_t)ret_conv;
8693 }
8694
8695 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8696         if ((_res & 1) != 0) return;
8697         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8698         FREE((void*)_res);
8699         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8700 }
8701
8702 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8703         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8704         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8705         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8706         return (uint64_t)ret_conv;
8707 }
8708
8709 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
8710         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8711         *ret_conv = CResult_NoneNoneZ_ok();
8712         return (uint64_t)ret_conv;
8713 }
8714
8715 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
8716         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8717         *ret_conv = CResult_NoneNoneZ_err();
8718         return (uint64_t)ret_conv;
8719 }
8720
8721 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
8722         if ((_res & 1) != 0) return;
8723         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1);
8724         FREE((void*)_res);
8725         CResult_NoneNoneZ_free(_res_conv);
8726 }
8727
8728 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
8729         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
8730         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8731         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
8732         return (uint64_t)ret_conv;
8733 }
8734
8735 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
8736         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8737         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8738         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8739         return ((uint64_t)ret_conv);
8740 }
8741
8742 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
8743         LDKSignature a_ref;
8744         CHECK(*((uint32_t*)a) == 64);
8745         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
8746         LDKCVec_SignatureZ b_constr;
8747         b_constr.datalen = *((uint32_t*)b);
8748         if (b_constr.datalen > 0)
8749                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8750         else
8751                 b_constr.data = NULL;
8752         int8_tArray* b_vals = (int8_tArray*)(b + 4);
8753         for (size_t m = 0; m < b_constr.datalen; m++) {
8754                 int8_tArray b_conv_12 = b_vals[m];
8755                 LDKSignature b_conv_12_ref;
8756                 CHECK(*((uint32_t*)b_conv_12) == 64);
8757                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
8758                 b_constr.data[m] = b_conv_12_ref;
8759         }
8760         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8761         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8762         return ((uint64_t)ret_conv);
8763 }
8764
8765 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
8766         if ((_res & 1) != 0) return;
8767         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8768         FREE((void*)_res);
8769         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8770 }
8771
8772 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
8773         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8774         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
8775         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8776         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8777         return (uint64_t)ret_conv;
8778 }
8779
8780 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
8781         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8782         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8783         return (uint64_t)ret_conv;
8784 }
8785
8786 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
8787         if ((_res & 1) != 0) return;
8788         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8789         FREE((void*)_res);
8790         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8791 }
8792
8793 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
8794         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8795         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8796         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8797         return (uint64_t)ret_conv;
8798 }
8799
8800 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
8801         LDKSignature o_ref;
8802         CHECK(*((uint32_t*)o) == 64);
8803         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
8804         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8805         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8806         return (uint64_t)ret_conv;
8807 }
8808
8809 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
8810         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8811         *ret_conv = CResult_SignatureNoneZ_err();
8812         return (uint64_t)ret_conv;
8813 }
8814
8815 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
8816         if ((_res & 1) != 0) return;
8817         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8818         FREE((void*)_res);
8819         CResult_SignatureNoneZ_free(_res_conv);
8820 }
8821
8822 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
8823         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8824         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8825         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8826         return (uint64_t)ret_conv;
8827 }
8828
8829 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
8830         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8831         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8832         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8833         return (uint64_t)ret_conv;
8834 }
8835
8836 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
8837         LDKDecodeError e_conv;
8838         e_conv.inner = (void*)(e & (~1));
8839         e_conv.is_owned = (e & 1) || (e == 0);
8840         e_conv = DecodeError_clone(&e_conv);
8841         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8842         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8843         return (uint64_t)ret_conv;
8844 }
8845
8846 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
8847         if ((_res & 1) != 0) return;
8848         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8849         FREE((void*)_res);
8850         CResult_SignDecodeErrorZ_free(_res_conv);
8851 }
8852
8853 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
8854         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8855         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8856         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8857         return (uint64_t)ret_conv;
8858 }
8859
8860 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
8861         LDKCVec_u8Z _res_ref;
8862         _res_ref.datalen = *((uint32_t*)_res);
8863         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
8864         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
8865         CVec_u8Z_free(_res_ref);
8866 }
8867
8868 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
8869         LDKRecoverableSignature arg_ref;
8870         CHECK(*((uint32_t*)arg) == 68);
8871         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
8872         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8873         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
8874         return (uint64_t)ret_conv;
8875 }
8876
8877 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
8878         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8879         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
8880         return (uint64_t)ret_conv;
8881 }
8882
8883 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
8884         if ((_res & 1) != 0) return;
8885         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
8886         FREE((void*)_res);
8887         CResult_RecoverableSignatureNoneZ_free(_res_conv);
8888 }
8889
8890 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
8891         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
8892         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8893         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
8894         return (uint64_t)ret_conv;
8895 }
8896
8897 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
8898         LDKCVec_CVec_u8ZZ _res_constr;
8899         _res_constr.datalen = *((uint32_t*)_res);
8900         if (_res_constr.datalen > 0)
8901                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8902         else
8903                 _res_constr.data = NULL;
8904         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8905         for (size_t m = 0; m < _res_constr.datalen; m++) {
8906                 int8_tArray _res_conv_12 = _res_vals[m];
8907                 LDKCVec_u8Z _res_conv_12_ref;
8908                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8909                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8910                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8911                 _res_constr.data[m] = _res_conv_12_ref;
8912         }
8913         CVec_CVec_u8ZZ_free(_res_constr);
8914 }
8915
8916 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
8917         LDKCVec_CVec_u8ZZ o_constr;
8918         o_constr.datalen = *((uint32_t*)o);
8919         if (o_constr.datalen > 0)
8920                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8921         else
8922                 o_constr.data = NULL;
8923         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8924         for (size_t m = 0; m < o_constr.datalen; m++) {
8925                 int8_tArray o_conv_12 = o_vals[m];
8926                 LDKCVec_u8Z o_conv_12_ref;
8927                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
8928                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8929                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
8930                 o_constr.data[m] = o_conv_12_ref;
8931         }
8932         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8933         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8934         return (uint64_t)ret_conv;
8935 }
8936
8937 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
8938         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8939         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8940         return (uint64_t)ret_conv;
8941 }
8942
8943 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
8944         if ((_res & 1) != 0) return;
8945         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8946         FREE((void*)_res);
8947         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8948 }
8949
8950 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
8951         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8952         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8953         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8954         return (uint64_t)ret_conv;
8955 }
8956
8957 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
8958         LDKInMemorySigner o_conv;
8959         o_conv.inner = (void*)(o & (~1));
8960         o_conv.is_owned = (o & 1) || (o == 0);
8961         o_conv = InMemorySigner_clone(&o_conv);
8962         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8963         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8964         return (uint64_t)ret_conv;
8965 }
8966
8967 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
8968         LDKDecodeError e_conv;
8969         e_conv.inner = (void*)(e & (~1));
8970         e_conv.is_owned = (e & 1) || (e == 0);
8971         e_conv = DecodeError_clone(&e_conv);
8972         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8973         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8974         return (uint64_t)ret_conv;
8975 }
8976
8977 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
8978         if ((_res & 1) != 0) return;
8979         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8980         FREE((void*)_res);
8981         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8982 }
8983
8984 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
8985         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8986         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8987         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8988         return (uint64_t)ret_conv;
8989 }
8990
8991 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
8992         LDKCVec_TxOutZ _res_constr;
8993         _res_constr.datalen = *((uint32_t*)_res);
8994         if (_res_constr.datalen > 0)
8995                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8996         else
8997                 _res_constr.data = NULL;
8998         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8999         for (size_t h = 0; h < _res_constr.datalen; h++) {
9000                 uint32_t _res_conv_7 = _res_vals[h];
9001                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
9002                 FREE((void*)_res_conv_7);
9003                 _res_constr.data[h] = _res_conv_7_conv;
9004         }
9005         CVec_TxOutZ_free(_res_constr);
9006 }
9007
9008 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
9009         LDKTransaction o_ref;
9010         o_ref.datalen = *((uint32_t*)o);
9011         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
9012         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
9013         o_ref.data_is_owned = true;
9014         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
9015         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
9016         return (uint64_t)ret_conv;
9017 }
9018
9019 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
9020         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
9021         *ret_conv = CResult_TransactionNoneZ_err();
9022         return (uint64_t)ret_conv;
9023 }
9024
9025 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
9026         if ((_res & 1) != 0) return;
9027         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
9028         FREE((void*)_res);
9029         CResult_TransactionNoneZ_free(_res_conv);
9030 }
9031
9032 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
9033         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
9034         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
9035         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
9036         return (uint64_t)ret_conv;
9037 }
9038
9039 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
9040         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
9041         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
9042         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
9043         return ((uint64_t)ret_conv);
9044 }
9045
9046 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
9047         LDKThirtyTwoBytes a_ref;
9048         CHECK(*((uint32_t*)a) == 32);
9049         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9050         LDKChannelMonitor b_conv;
9051         b_conv.inner = (void*)(b & (~1));
9052         b_conv.is_owned = (b & 1) || (b == 0);
9053         b_conv = ChannelMonitor_clone(&b_conv);
9054         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
9055         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
9056         return ((uint64_t)ret_conv);
9057 }
9058
9059 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
9060         if ((_res & 1) != 0) return;
9061         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
9062         FREE((void*)_res);
9063         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
9064 }
9065
9066 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
9067         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
9068         _res_constr.datalen = *((uint32_t*)_res);
9069         if (_res_constr.datalen > 0)
9070                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
9071         else
9072                 _res_constr.data = NULL;
9073         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9074         for (size_t j = 0; j < _res_constr.datalen; j++) {
9075                 uint32_t _res_conv_35 = _res_vals[j];
9076                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
9077                 FREE((void*)_res_conv_35);
9078                 _res_constr.data[j] = _res_conv_35_conv;
9079         }
9080         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
9081 }
9082
9083 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
9084         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
9085         o_constr.datalen = *((uint32_t*)o);
9086         if (o_constr.datalen > 0)
9087                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
9088         else
9089                 o_constr.data = NULL;
9090         uint32_t* o_vals = (uint32_t*)(o + 4);
9091         for (size_t j = 0; j < o_constr.datalen; j++) {
9092                 uint32_t o_conv_35 = o_vals[j];
9093                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
9094                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
9095                 o_constr.data[j] = o_conv_35_conv;
9096         }
9097         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
9098         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
9099         return (uint64_t)ret_conv;
9100 }
9101
9102 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
9103         LDKIOError e_conv = LDKIOError_from_js(e);
9104         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
9105         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
9106         return (uint64_t)ret_conv;
9107 }
9108
9109 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
9110         if ((_res & 1) != 0) return;
9111         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
9112         FREE((void*)_res);
9113         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
9114 }
9115
9116 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(uint32_t orig) {
9117         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
9118         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
9119         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
9120         return (uint64_t)ret_conv;
9121 }
9122
9123 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_ok(uint32_t o) {
9124         LDKPaymentId o_conv;
9125         o_conv.inner = (void*)(o & (~1));
9126         o_conv.is_owned = (o & 1) || (o == 0);
9127         o_conv = PaymentId_clone(&o_conv);
9128         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
9129         *ret_conv = CResult_PaymentIdDecodeErrorZ_ok(o_conv);
9130         return (uint64_t)ret_conv;
9131 }
9132
9133 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_err(uint32_t e) {
9134         LDKDecodeError e_conv;
9135         e_conv.inner = (void*)(e & (~1));
9136         e_conv.is_owned = (e & 1) || (e == 0);
9137         e_conv = DecodeError_clone(&e_conv);
9138         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
9139         *ret_conv = CResult_PaymentIdDecodeErrorZ_err(e_conv);
9140         return (uint64_t)ret_conv;
9141 }
9142
9143 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_free(uint32_t _res) {
9144         if ((_res & 1) != 0) return;
9145         LDKCResult_PaymentIdDecodeErrorZ _res_conv = *(LDKCResult_PaymentIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
9146         FREE((void*)_res);
9147         CResult_PaymentIdDecodeErrorZ_free(_res_conv);
9148 }
9149
9150 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdDecodeErrorZ_clone(uint32_t orig) {
9151         LDKCResult_PaymentIdDecodeErrorZ* orig_conv = (LDKCResult_PaymentIdDecodeErrorZ*)(orig & ~1);
9152         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
9153         *ret_conv = CResult_PaymentIdDecodeErrorZ_clone(orig_conv);
9154         return (uint64_t)ret_conv;
9155 }
9156
9157 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
9158         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
9159         *ret_copy = COption_u16Z_some(o);
9160         uint64_t ret_ref = (uint64_t)ret_copy;
9161         return ret_ref;
9162 }
9163
9164 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
9165         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
9166         *ret_copy = COption_u16Z_none();
9167         uint64_t ret_ref = (uint64_t)ret_copy;
9168         return ret_ref;
9169 }
9170
9171 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
9172         if ((_res & 1) != 0) return;
9173         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
9174         FREE((void*)_res);
9175         COption_u16Z_free(_res_conv);
9176 }
9177
9178 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
9179         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
9180         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
9181         *ret_copy = COption_u16Z_clone(orig_conv);
9182         uint64_t ret_ref = (uint64_t)ret_copy;
9183         return ret_ref;
9184 }
9185
9186 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
9187         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
9188         *ret_conv = CResult_NoneAPIErrorZ_ok();
9189         return (uint64_t)ret_conv;
9190 }
9191
9192 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
9193         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
9194         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
9195         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
9196         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
9197         return (uint64_t)ret_conv;
9198 }
9199
9200 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
9201         if ((_res & 1) != 0) return;
9202         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
9203         FREE((void*)_res);
9204         CResult_NoneAPIErrorZ_free(_res_conv);
9205 }
9206
9207 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
9208         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
9209         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
9210         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
9211         return (uint64_t)ret_conv;
9212 }
9213
9214 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
9215         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
9216         _res_constr.datalen = *((uint32_t*)_res);
9217         if (_res_constr.datalen > 0)
9218                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
9219         else
9220                 _res_constr.data = NULL;
9221         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9222         for (size_t w = 0; w < _res_constr.datalen; w++) {
9223                 uint32_t _res_conv_22 = _res_vals[w];
9224                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
9225                 FREE((void*)_res_conv_22);
9226                 _res_constr.data[w] = _res_conv_22_conv;
9227         }
9228         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
9229 }
9230
9231 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
9232         LDKCVec_APIErrorZ _res_constr;
9233         _res_constr.datalen = *((uint32_t*)_res);
9234         if (_res_constr.datalen > 0)
9235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
9236         else
9237                 _res_constr.data = NULL;
9238         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9239         for (size_t k = 0; k < _res_constr.datalen; k++) {
9240                 uint32_t _res_conv_10 = _res_vals[k];
9241                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
9242                 FREE((void*)_res_conv_10);
9243                 _res_constr.data[k] = _res_conv_10_conv;
9244         }
9245         CVec_APIErrorZ_free(_res_constr);
9246 }
9247
9248 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
9249         LDKThirtyTwoBytes o_ref;
9250         CHECK(*((uint32_t*)o) == 32);
9251         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
9252         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
9253         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
9254         return (uint64_t)ret_conv;
9255 }
9256
9257 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
9258         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
9259         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
9260         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
9261         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
9262         return (uint64_t)ret_conv;
9263 }
9264
9265 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
9266         if ((_res & 1) != 0) return;
9267         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(((uint64_t)_res) & ~1);
9268         FREE((void*)_res);
9269         CResult__u832APIErrorZ_free(_res_conv);
9270 }
9271
9272 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
9273         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
9274         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
9275         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
9276         return (uint64_t)ret_conv;
9277 }
9278
9279 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(uint32_t o) {
9280         LDKPaymentId o_conv;
9281         o_conv.inner = (void*)(o & (~1));
9282         o_conv.is_owned = (o & 1) || (o == 0);
9283         o_conv = PaymentId_clone(&o_conv);
9284         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
9285         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_conv);
9286         return (uint64_t)ret_conv;
9287 }
9288
9289 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
9290         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
9291         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
9292         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
9293         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
9294         return (uint64_t)ret_conv;
9295 }
9296
9297 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
9298         if ((_res & 1) != 0) return;
9299         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9300         FREE((void*)_res);
9301         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
9302 }
9303
9304 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
9305         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
9306         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
9307         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
9308         return (uint64_t)ret_conv;
9309 }
9310
9311 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
9312         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9313         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
9314         return (uint64_t)ret_conv;
9315 }
9316
9317 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
9318         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
9319         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
9320         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9321         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
9322         return (uint64_t)ret_conv;
9323 }
9324
9325 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
9326         if ((_res & 1) != 0) return;
9327         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9328         FREE((void*)_res);
9329         CResult_NonePaymentSendFailureZ_free(_res_conv);
9330 }
9331
9332 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
9333         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
9334         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9335         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
9336         return (uint64_t)ret_conv;
9337 }
9338
9339 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
9340         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
9341         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
9342         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
9343         return ((uint64_t)ret_conv);
9344 }
9345
9346 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, uint32_t b) {
9347         LDKThirtyTwoBytes a_ref;
9348         CHECK(*((uint32_t*)a) == 32);
9349         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9350         LDKPaymentId b_conv;
9351         b_conv.inner = (void*)(b & (~1));
9352         b_conv.is_owned = (b & 1) || (b == 0);
9353         b_conv = PaymentId_clone(&b_conv);
9354         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
9355         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_conv);
9356         return ((uint64_t)ret_conv);
9357 }
9358
9359 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
9360         if ((_res & 1) != 0) return;
9361         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)_res) & ~1);
9362         FREE((void*)_res);
9363         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
9364 }
9365
9366 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
9367         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1);
9368         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
9369         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
9370         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
9371         return (uint64_t)ret_conv;
9372 }
9373
9374 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
9375         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
9376         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
9377         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
9378         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
9379         return (uint64_t)ret_conv;
9380 }
9381
9382 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
9383         if ((_res & 1) != 0) return;
9384         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9385         FREE((void*)_res);
9386         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
9387 }
9388
9389 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
9390         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
9391         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
9392         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
9393         return (uint64_t)ret_conv;
9394 }
9395
9396 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
9397         LDKCVec_NetAddressZ _res_constr;
9398         _res_constr.datalen = *((uint32_t*)_res);
9399         if (_res_constr.datalen > 0)
9400                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9401         else
9402                 _res_constr.data = NULL;
9403         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9404         for (size_t m = 0; m < _res_constr.datalen; m++) {
9405                 uint32_t _res_conv_12 = _res_vals[m];
9406                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
9407                 FREE((void*)_res_conv_12);
9408                 _res_constr.data[m] = _res_conv_12_conv;
9409         }
9410         CVec_NetAddressZ_free(_res_constr);
9411 }
9412
9413 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
9414         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
9415         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
9416         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
9417         return ((uint64_t)ret_conv);
9418 }
9419
9420 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
9421         LDKThirtyTwoBytes a_ref;
9422         CHECK(*((uint32_t*)a) == 32);
9423         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9424         LDKThirtyTwoBytes b_ref;
9425         CHECK(*((uint32_t*)b) == 32);
9426         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
9427         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
9428         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
9429         return ((uint64_t)ret_conv);
9430 }
9431
9432 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
9433         if ((_res & 1) != 0) return;
9434         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
9435         FREE((void*)_res);
9436         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
9437 }
9438
9439 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
9440         LDKThirtyTwoBytes o_ref;
9441         CHECK(*((uint32_t*)o) == 32);
9442         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
9443         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9444         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
9445         return (uint64_t)ret_conv;
9446 }
9447
9448 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
9449         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
9450         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
9451         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9452         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
9453         return (uint64_t)ret_conv;
9454 }
9455
9456 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
9457         if ((_res & 1) != 0) return;
9458         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
9459         FREE((void*)_res);
9460         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
9461 }
9462
9463 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
9464         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
9465         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9466         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
9467         return (uint64_t)ret_conv;
9468 }
9469
9470 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
9471         LDKCVec_ChannelMonitorZ _res_constr;
9472         _res_constr.datalen = *((uint32_t*)_res);
9473         if (_res_constr.datalen > 0)
9474                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
9475         else
9476                 _res_constr.data = NULL;
9477         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9478         for (size_t q = 0; q < _res_constr.datalen; q++) {
9479                 uint32_t _res_conv_16 = _res_vals[q];
9480                 LDKChannelMonitor _res_conv_16_conv;
9481                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9482                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9483                 _res_constr.data[q] = _res_conv_16_conv;
9484         }
9485         CVec_ChannelMonitorZ_free(_res_constr);
9486 }
9487
9488 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
9489         LDKThirtyTwoBytes a_ref;
9490         CHECK(*((uint32_t*)a) == 32);
9491         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9492         LDKChannelManager b_conv;
9493         b_conv.inner = (void*)(b & (~1));
9494         b_conv.is_owned = (b & 1) || (b == 0);
9495         // Warning: we need a move here but no clone is available for LDKChannelManager
9496         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
9497         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
9498         return ((uint64_t)ret_conv);
9499 }
9500
9501 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
9502         if ((_res & 1) != 0) return;
9503         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
9504         FREE((void*)_res);
9505         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
9506 }
9507
9508 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
9509         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
9510         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
9511         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9512         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
9513         return (uint64_t)ret_conv;
9514 }
9515
9516 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
9517         LDKDecodeError e_conv;
9518         e_conv.inner = (void*)(e & (~1));
9519         e_conv.is_owned = (e & 1) || (e == 0);
9520         e_conv = DecodeError_clone(&e_conv);
9521         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9522         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
9523         return (uint64_t)ret_conv;
9524 }
9525
9526 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
9527         if ((_res & 1) != 0) return;
9528         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9529         FREE((void*)_res);
9530         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
9531 }
9532
9533 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
9534         LDKChannelConfig o_conv;
9535         o_conv.inner = (void*)(o & (~1));
9536         o_conv.is_owned = (o & 1) || (o == 0);
9537         o_conv = ChannelConfig_clone(&o_conv);
9538         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9539         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
9540         return (uint64_t)ret_conv;
9541 }
9542
9543 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
9544         LDKDecodeError e_conv;
9545         e_conv.inner = (void*)(e & (~1));
9546         e_conv.is_owned = (e & 1) || (e == 0);
9547         e_conv = DecodeError_clone(&e_conv);
9548         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9549         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9550         return (uint64_t)ret_conv;
9551 }
9552
9553 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9554         if ((_res & 1) != 0) return;
9555         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
9556         FREE((void*)_res);
9557         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9558 }
9559
9560 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9561         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9562         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9563         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9564         return (uint64_t)ret_conv;
9565 }
9566
9567 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9568         LDKOutPoint o_conv;
9569         o_conv.inner = (void*)(o & (~1));
9570         o_conv.is_owned = (o & 1) || (o == 0);
9571         o_conv = OutPoint_clone(&o_conv);
9572         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9573         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9574         return (uint64_t)ret_conv;
9575 }
9576
9577 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9578         LDKDecodeError e_conv;
9579         e_conv.inner = (void*)(e & (~1));
9580         e_conv.is_owned = (e & 1) || (e == 0);
9581         e_conv = DecodeError_clone(&e_conv);
9582         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9583         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9584         return (uint64_t)ret_conv;
9585 }
9586
9587 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9588         if ((_res & 1) != 0) return;
9589         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
9590         FREE((void*)_res);
9591         CResult_OutPointDecodeErrorZ_free(_res_conv);
9592 }
9593
9594 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9595         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9596         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9597         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9598         return (uint64_t)ret_conv;
9599 }
9600
9601 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
9602         LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
9603         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9604         *ret_copy = COption_TypeZ_some(o_conv);
9605         uint64_t ret_ref = (uint64_t)ret_copy;
9606         return ret_ref;
9607 }
9608
9609 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
9610         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9611         *ret_copy = COption_TypeZ_none();
9612         uint64_t ret_ref = (uint64_t)ret_copy;
9613         return ret_ref;
9614 }
9615
9616 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
9617         if ((_res & 1) != 0) return;
9618         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1);
9619         FREE((void*)_res);
9620         COption_TypeZ_free(_res_conv);
9621 }
9622
9623 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
9624         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
9625         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9626         *ret_copy = COption_TypeZ_clone(orig_conv);
9627         uint64_t ret_ref = (uint64_t)ret_copy;
9628         return ret_ref;
9629 }
9630
9631 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
9632         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
9633         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
9634         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9635         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
9636         return (uint64_t)ret_conv;
9637 }
9638
9639 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
9640         LDKDecodeError e_conv;
9641         e_conv.inner = (void*)(e & (~1));
9642         e_conv.is_owned = (e & 1) || (e == 0);
9643         e_conv = DecodeError_clone(&e_conv);
9644         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9645         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
9646         return (uint64_t)ret_conv;
9647 }
9648
9649 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
9650         if ((_res & 1) != 0) return;
9651         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9652         FREE((void*)_res);
9653         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
9654 }
9655
9656 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
9657         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
9658         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9659         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
9664         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
9665         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9666         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
9667         return (uint64_t)ret_conv;
9668 }
9669
9670 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
9671         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9672         *ret_conv = CResult_SiPrefixNoneZ_err();
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
9677         if ((_res & 1) != 0) return;
9678         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
9679         FREE((void*)_res);
9680         CResult_SiPrefixNoneZ_free(_res_conv);
9681 }
9682
9683 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
9684         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
9685         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9686         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
9687         return (uint64_t)ret_conv;
9688 }
9689
9690 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
9691         LDKInvoice o_conv;
9692         o_conv.inner = (void*)(o & (~1));
9693         o_conv.is_owned = (o & 1) || (o == 0);
9694         o_conv = Invoice_clone(&o_conv);
9695         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9696         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
9697         return (uint64_t)ret_conv;
9698 }
9699
9700 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
9701         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9702         *ret_conv = CResult_InvoiceNoneZ_err();
9703         return (uint64_t)ret_conv;
9704 }
9705
9706 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
9707         if ((_res & 1) != 0) return;
9708         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
9709         FREE((void*)_res);
9710         CResult_InvoiceNoneZ_free(_res_conv);
9711 }
9712
9713 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
9714         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
9715         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9716         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
9717         return (uint64_t)ret_conv;
9718 }
9719
9720 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
9721         LDKSignedRawInvoice o_conv;
9722         o_conv.inner = (void*)(o & (~1));
9723         o_conv.is_owned = (o & 1) || (o == 0);
9724         o_conv = SignedRawInvoice_clone(&o_conv);
9725         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9726         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
9727         return (uint64_t)ret_conv;
9728 }
9729
9730 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
9731         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9732         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
9733         return (uint64_t)ret_conv;
9734 }
9735
9736 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
9737         if ((_res & 1) != 0) return;
9738         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
9739         FREE((void*)_res);
9740         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
9741 }
9742
9743 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
9744         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
9745         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9746         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
9747         return (uint64_t)ret_conv;
9748 }
9749
9750 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
9751         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
9752         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9753         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
9754         return ((uint64_t)ret_conv);
9755 }
9756
9757 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
9758         LDKRawInvoice a_conv;
9759         a_conv.inner = (void*)(a & (~1));
9760         a_conv.is_owned = (a & 1) || (a == 0);
9761         a_conv = RawInvoice_clone(&a_conv);
9762         LDKThirtyTwoBytes b_ref;
9763         CHECK(*((uint32_t*)b) == 32);
9764         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
9765         LDKInvoiceSignature c_conv;
9766         c_conv.inner = (void*)(c & (~1));
9767         c_conv.is_owned = (c & 1) || (c == 0);
9768         c_conv = InvoiceSignature_clone(&c_conv);
9769         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9770         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
9771         return ((uint64_t)ret_conv);
9772 }
9773
9774 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
9775         if ((_res & 1) != 0) return;
9776         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
9777         FREE((void*)_res);
9778         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
9779 }
9780
9781 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
9782         LDKPayeePubKey o_conv;
9783         o_conv.inner = (void*)(o & (~1));
9784         o_conv.is_owned = (o & 1) || (o == 0);
9785         o_conv = PayeePubKey_clone(&o_conv);
9786         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9787         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
9788         return (uint64_t)ret_conv;
9789 }
9790
9791 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
9792         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9793         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9794         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
9795         return (uint64_t)ret_conv;
9796 }
9797
9798 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
9799         if ((_res & 1) != 0) return;
9800         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
9801         FREE((void*)_res);
9802         CResult_PayeePubKeyErrorZ_free(_res_conv);
9803 }
9804
9805 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
9806         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
9807         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9808         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
9809         return (uint64_t)ret_conv;
9810 }
9811
9812 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
9813         LDKCVec_PrivateRouteZ _res_constr;
9814         _res_constr.datalen = *((uint32_t*)_res);
9815         if (_res_constr.datalen > 0)
9816                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
9817         else
9818                 _res_constr.data = NULL;
9819         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9820         for (size_t o = 0; o < _res_constr.datalen; o++) {
9821                 uint32_t _res_conv_14 = _res_vals[o];
9822                 LDKPrivateRoute _res_conv_14_conv;
9823                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9824                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9825                 _res_constr.data[o] = _res_conv_14_conv;
9826         }
9827         CVec_PrivateRouteZ_free(_res_constr);
9828 }
9829
9830 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
9831         LDKPositiveTimestamp o_conv;
9832         o_conv.inner = (void*)(o & (~1));
9833         o_conv.is_owned = (o & 1) || (o == 0);
9834         o_conv = PositiveTimestamp_clone(&o_conv);
9835         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9836         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
9837         return (uint64_t)ret_conv;
9838 }
9839
9840 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
9841         LDKCreationError e_conv = LDKCreationError_from_js(e);
9842         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9843         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
9844         return (uint64_t)ret_conv;
9845 }
9846
9847 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
9848         if ((_res & 1) != 0) return;
9849         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
9850         FREE((void*)_res);
9851         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
9852 }
9853
9854 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
9855         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
9856         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9857         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
9858         return (uint64_t)ret_conv;
9859 }
9860
9861 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
9862         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9863         *ret_conv = CResult_NoneSemanticErrorZ_ok();
9864         return (uint64_t)ret_conv;
9865 }
9866
9867 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
9868         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9869         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9870         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
9871         return (uint64_t)ret_conv;
9872 }
9873
9874 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
9875         if ((_res & 1) != 0) return;
9876         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
9877         FREE((void*)_res);
9878         CResult_NoneSemanticErrorZ_free(_res_conv);
9879 }
9880
9881 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
9882         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
9883         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9884         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
9885         return (uint64_t)ret_conv;
9886 }
9887
9888 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
9889         LDKInvoice o_conv;
9890         o_conv.inner = (void*)(o & (~1));
9891         o_conv.is_owned = (o & 1) || (o == 0);
9892         o_conv = Invoice_clone(&o_conv);
9893         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9894         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
9895         return (uint64_t)ret_conv;
9896 }
9897
9898 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
9899         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9900         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9901         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
9902         return (uint64_t)ret_conv;
9903 }
9904
9905 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
9906         if ((_res & 1) != 0) return;
9907         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
9908         FREE((void*)_res);
9909         CResult_InvoiceSemanticErrorZ_free(_res_conv);
9910 }
9911
9912 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
9913         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
9914         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9915         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
9916         return (uint64_t)ret_conv;
9917 }
9918
9919 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
9920         LDKDescription o_conv;
9921         o_conv.inner = (void*)(o & (~1));
9922         o_conv.is_owned = (o & 1) || (o == 0);
9923         o_conv = Description_clone(&o_conv);
9924         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9925         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
9926         return (uint64_t)ret_conv;
9927 }
9928
9929 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
9930         LDKCreationError e_conv = LDKCreationError_from_js(e);
9931         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9932         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
9933         return (uint64_t)ret_conv;
9934 }
9935
9936 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
9937         if ((_res & 1) != 0) return;
9938         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
9939         FREE((void*)_res);
9940         CResult_DescriptionCreationErrorZ_free(_res_conv);
9941 }
9942
9943 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
9944         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
9945         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9946         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
9947         return (uint64_t)ret_conv;
9948 }
9949
9950 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
9951         LDKExpiryTime o_conv;
9952         o_conv.inner = (void*)(o & (~1));
9953         o_conv.is_owned = (o & 1) || (o == 0);
9954         o_conv = ExpiryTime_clone(&o_conv);
9955         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9956         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
9957         return (uint64_t)ret_conv;
9958 }
9959
9960 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
9961         LDKCreationError e_conv = LDKCreationError_from_js(e);
9962         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9963         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
9964         return (uint64_t)ret_conv;
9965 }
9966
9967 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
9968         if ((_res & 1) != 0) return;
9969         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
9970         FREE((void*)_res);
9971         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
9972 }
9973
9974 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
9975         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
9976         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9977         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
9978         return (uint64_t)ret_conv;
9979 }
9980
9981 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
9982         LDKPrivateRoute o_conv;
9983         o_conv.inner = (void*)(o & (~1));
9984         o_conv.is_owned = (o & 1) || (o == 0);
9985         o_conv = PrivateRoute_clone(&o_conv);
9986         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9987         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
9988         return (uint64_t)ret_conv;
9989 }
9990
9991 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
9992         LDKCreationError e_conv = LDKCreationError_from_js(e);
9993         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9994         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
9995         return (uint64_t)ret_conv;
9996 }
9997
9998 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
9999         if ((_res & 1) != 0) return;
10000         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
10001         FREE((void*)_res);
10002         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
10003 }
10004
10005 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
10006         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
10007         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
10008         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
10009         return (uint64_t)ret_conv;
10010 }
10011
10012 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
10013         LDKStr o_conv = str_ref_to_owned_c(o);
10014         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10015         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10016         return (uint64_t)ret_conv;
10017 }
10018
10019 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
10020         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10021         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10022         *ret_conv = CResult_StringErrorZ_err(e_conv);
10023         return (uint64_t)ret_conv;
10024 }
10025
10026 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
10027         if ((_res & 1) != 0) return;
10028         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
10029         FREE((void*)_res);
10030         CResult_StringErrorZ_free(_res_conv);
10031 }
10032
10033 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
10034         LDKChannelMonitorUpdate o_conv;
10035         o_conv.inner = (void*)(o & (~1));
10036         o_conv.is_owned = (o & 1) || (o == 0);
10037         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10038         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10039         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10040         return (uint64_t)ret_conv;
10041 }
10042
10043 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
10044         LDKDecodeError e_conv;
10045         e_conv.inner = (void*)(e & (~1));
10046         e_conv.is_owned = (e & 1) || (e == 0);
10047         e_conv = DecodeError_clone(&e_conv);
10048         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10049         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10050         return (uint64_t)ret_conv;
10051 }
10052
10053 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
10054         if ((_res & 1) != 0) return;
10055         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10056         FREE((void*)_res);
10057         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10058 }
10059
10060 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
10061         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10062         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10063         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10064         return (uint64_t)ret_conv;
10065 }
10066
10067 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
10068         LDKHTLCUpdate o_conv;
10069         o_conv.inner = (void*)(o & (~1));
10070         o_conv.is_owned = (o & 1) || (o == 0);
10071         o_conv = HTLCUpdate_clone(&o_conv);
10072         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10073         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10074         return (uint64_t)ret_conv;
10075 }
10076
10077 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
10078         LDKDecodeError e_conv;
10079         e_conv.inner = (void*)(e & (~1));
10080         e_conv.is_owned = (e & 1) || (e == 0);
10081         e_conv = DecodeError_clone(&e_conv);
10082         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10083         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10084         return (uint64_t)ret_conv;
10085 }
10086
10087 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
10088         if ((_res & 1) != 0) return;
10089         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
10090         FREE((void*)_res);
10091         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10092 }
10093
10094 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
10095         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10096         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10097         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10098         return (uint64_t)ret_conv;
10099 }
10100
10101 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
10102         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10103         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
10104         return (uint64_t)ret_conv;
10105 }
10106
10107 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
10108         LDKMonitorUpdateError e_conv;
10109         e_conv.inner = (void*)(e & (~1));
10110         e_conv.is_owned = (e & 1) || (e == 0);
10111         e_conv = MonitorUpdateError_clone(&e_conv);
10112         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10113         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
10114         return (uint64_t)ret_conv;
10115 }
10116
10117 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
10118         if ((_res & 1) != 0) return;
10119         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
10120         FREE((void*)_res);
10121         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
10122 }
10123
10124 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
10125         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
10126         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
10127         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
10128         return (uint64_t)ret_conv;
10129 }
10130
10131 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
10132         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
10133         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10134         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
10135         return ((uint64_t)ret_conv);
10136 }
10137
10138 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
10139         LDKOutPoint a_conv;
10140         a_conv.inner = (void*)(a & (~1));
10141         a_conv.is_owned = (a & 1) || (a == 0);
10142         a_conv = OutPoint_clone(&a_conv);
10143         LDKCVec_u8Z b_ref;
10144         b_ref.datalen = *((uint32_t*)b);
10145         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10146         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
10147         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10148         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10149         return ((uint64_t)ret_conv);
10150 }
10151
10152 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
10153         if ((_res & 1) != 0) return;
10154         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
10155         FREE((void*)_res);
10156         C2Tuple_OutPointScriptZ_free(_res_conv);
10157 }
10158
10159 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
10160         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
10161         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10162         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
10163         return ((uint64_t)ret_conv);
10164 }
10165
10166 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
10167         LDKCVec_u8Z b_ref;
10168         b_ref.datalen = *((uint32_t*)b);
10169         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10170         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
10171         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10172         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
10173         return ((uint64_t)ret_conv);
10174 }
10175
10176 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
10177         if ((_res & 1) != 0) return;
10178         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
10179         FREE((void*)_res);
10180         C2Tuple_u32ScriptZ_free(_res_conv);
10181 }
10182
10183 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
10184         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10185         _res_constr.datalen = *((uint32_t*)_res);
10186         if (_res_constr.datalen > 0)
10187                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10188         else
10189                 _res_constr.data = NULL;
10190         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10191         for (size_t v = 0; v < _res_constr.datalen; v++) {
10192                 uint32_t _res_conv_21 = _res_vals[v];
10193                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
10194                 FREE((void*)_res_conv_21);
10195                 _res_constr.data[v] = _res_conv_21_conv;
10196         }
10197         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10198 }
10199
10200 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
10201         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
10202         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10203         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
10204         return ((uint64_t)ret_conv);
10205 }
10206
10207 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
10208         LDKThirtyTwoBytes a_ref;
10209         CHECK(*((uint32_t*)a) == 32);
10210         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10211         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10212         b_constr.datalen = *((uint32_t*)b);
10213         if (b_constr.datalen > 0)
10214                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10215         else
10216                 b_constr.data = NULL;
10217         uint32_t* b_vals = (uint32_t*)(b + 4);
10218         for (size_t v = 0; v < b_constr.datalen; v++) {
10219                 uint32_t b_conv_21 = b_vals[v];
10220                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
10221                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
10222                 b_constr.data[v] = b_conv_21_conv;
10223         }
10224         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10225         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10226         return ((uint64_t)ret_conv);
10227 }
10228
10229 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
10230         if ((_res & 1) != 0) return;
10231         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
10232         FREE((void*)_res);
10233         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10234 }
10235
10236 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
10237         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10238         _res_constr.datalen = *((uint32_t*)_res);
10239         if (_res_constr.datalen > 0)
10240                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10241         else
10242                 _res_constr.data = NULL;
10243         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10244         for (size_t o = 0; o < _res_constr.datalen; o++) {
10245                 uint32_t _res_conv_40 = _res_vals[o];
10246                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
10247                 FREE((void*)_res_conv_40);
10248                 _res_constr.data[o] = _res_conv_40_conv;
10249         }
10250         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
10251 }
10252
10253 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
10254         LDKCVec_EventZ _res_constr;
10255         _res_constr.datalen = *((uint32_t*)_res);
10256         if (_res_constr.datalen > 0)
10257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
10258         else
10259                 _res_constr.data = NULL;
10260         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10261         for (size_t h = 0; h < _res_constr.datalen; h++) {
10262                 uint32_t _res_conv_7 = _res_vals[h];
10263                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
10264                 FREE((void*)_res_conv_7);
10265                 _res_constr.data[h] = _res_conv_7_conv;
10266         }
10267         CVec_EventZ_free(_res_constr);
10268 }
10269
10270 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
10271         LDKCVec_TransactionZ _res_constr;
10272         _res_constr.datalen = *((uint32_t*)_res);
10273         if (_res_constr.datalen > 0)
10274                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
10275         else
10276                 _res_constr.data = NULL;
10277         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10278         for (size_t m = 0; m < _res_constr.datalen; m++) {
10279                 int8_tArray _res_conv_12 = _res_vals[m];
10280                 LDKTransaction _res_conv_12_ref;
10281                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
10282                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
10283                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
10284                 _res_conv_12_ref.data_is_owned = true;
10285                 _res_constr.data[m] = _res_conv_12_ref;
10286         }
10287         CVec_TransactionZ_free(_res_constr);
10288 }
10289
10290 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
10291         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
10292         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10293         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
10294         return ((uint64_t)ret_conv);
10295 }
10296
10297 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
10298         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
10299         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
10300         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10301         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
10302         return ((uint64_t)ret_conv);
10303 }
10304
10305 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
10306         if ((_res & 1) != 0) return;
10307         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
10308         FREE((void*)_res);
10309         C2Tuple_u32TxOutZ_free(_res_conv);
10310 }
10311
10312 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
10313         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
10314         _res_constr.datalen = *((uint32_t*)_res);
10315         if (_res_constr.datalen > 0)
10316                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10317         else
10318                 _res_constr.data = NULL;
10319         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10320         for (size_t u = 0; u < _res_constr.datalen; u++) {
10321                 uint32_t _res_conv_20 = _res_vals[u];
10322                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
10323                 FREE((void*)_res_conv_20);
10324                 _res_constr.data[u] = _res_conv_20_conv;
10325         }
10326         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
10327 }
10328
10329 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
10330         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
10331         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10332         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
10333         return ((uint64_t)ret_conv);
10334 }
10335
10336 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
10337         LDKThirtyTwoBytes a_ref;
10338         CHECK(*((uint32_t*)a) == 32);
10339         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10340         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
10341         b_constr.datalen = *((uint32_t*)b);
10342         if (b_constr.datalen > 0)
10343                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10344         else
10345                 b_constr.data = NULL;
10346         uint32_t* b_vals = (uint32_t*)(b + 4);
10347         for (size_t u = 0; u < b_constr.datalen; u++) {
10348                 uint32_t b_conv_20 = b_vals[u];
10349                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
10350                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
10351                 b_constr.data[u] = b_conv_20_conv;
10352         }
10353         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10354         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
10355         return ((uint64_t)ret_conv);
10356 }
10357
10358 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
10359         if ((_res & 1) != 0) return;
10360         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
10361         FREE((void*)_res);
10362         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
10363 }
10364
10365 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
10366         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
10367         _res_constr.datalen = *((uint32_t*)_res);
10368         if (_res_constr.datalen > 0)
10369                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
10370         else
10371                 _res_constr.data = NULL;
10372         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10373         for (size_t n = 0; n < _res_constr.datalen; n++) {
10374                 uint32_t _res_conv_39 = _res_vals[n];
10375                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
10376                 FREE((void*)_res_conv_39);
10377                 _res_constr.data[n] = _res_conv_39_conv;
10378         }
10379         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
10380 }
10381
10382 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
10383         LDKCVec_BalanceZ _res_constr;
10384         _res_constr.datalen = *((uint32_t*)_res);
10385         if (_res_constr.datalen > 0)
10386                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
10387         else
10388                 _res_constr.data = NULL;
10389         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10390         for (size_t j = 0; j < _res_constr.datalen; j++) {
10391                 uint32_t _res_conv_9 = _res_vals[j];
10392                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1);
10393                 FREE((void*)_res_conv_9);
10394                 _res_constr.data[j] = _res_conv_9_conv;
10395         }
10396         CVec_BalanceZ_free(_res_constr);
10397 }
10398
10399 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
10400         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
10401         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
10402         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10403         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
10404         return (uint64_t)ret_conv;
10405 }
10406
10407 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
10408         LDKDecodeError e_conv;
10409         e_conv.inner = (void*)(e & (~1));
10410         e_conv.is_owned = (e & 1) || (e == 0);
10411         e_conv = DecodeError_clone(&e_conv);
10412         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10413         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
10414         return (uint64_t)ret_conv;
10415 }
10416
10417 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
10418         if ((_res & 1) != 0) return;
10419         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10420         FREE((void*)_res);
10421         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
10422 }
10423
10424 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
10425         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
10426         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10427         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
10428         return (uint64_t)ret_conv;
10429 }
10430
10431 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
10432         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10433         *ret_conv = CResult_NoneLightningErrorZ_ok();
10434         return (uint64_t)ret_conv;
10435 }
10436
10437 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
10438         LDKLightningError e_conv;
10439         e_conv.inner = (void*)(e & (~1));
10440         e_conv.is_owned = (e & 1) || (e == 0);
10441         e_conv = LightningError_clone(&e_conv);
10442         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10443         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
10444         return (uint64_t)ret_conv;
10445 }
10446
10447 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
10448         if ((_res & 1) != 0) return;
10449         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
10450         FREE((void*)_res);
10451         CResult_NoneLightningErrorZ_free(_res_conv);
10452 }
10453
10454 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
10455         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
10456         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10457         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
10458         return (uint64_t)ret_conv;
10459 }
10460
10461 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
10462         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
10463         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10464         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
10465         return ((uint64_t)ret_conv);
10466 }
10467
10468 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
10469         LDKPublicKey a_ref;
10470         CHECK(*((uint32_t*)a) == 33);
10471         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
10472         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
10473         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10474         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
10475         return ((uint64_t)ret_conv);
10476 }
10477
10478 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
10479         if ((_res & 1) != 0) return;
10480         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1);
10481         FREE((void*)_res);
10482         C2Tuple_PublicKeyTypeZ_free(_res_conv);
10483 }
10484
10485 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
10486         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
10487         _res_constr.datalen = *((uint32_t*)_res);
10488         if (_res_constr.datalen > 0)
10489                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10490         else
10491                 _res_constr.data = NULL;
10492         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10493         for (size_t z = 0; z < _res_constr.datalen; z++) {
10494                 uint32_t _res_conv_25 = _res_vals[z];
10495                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
10496                 FREE((void*)_res_conv_25);
10497                 _res_constr.data[z] = _res_conv_25_conv;
10498         }
10499         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
10500 }
10501
10502 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
10503         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10504         *ret_conv = CResult_boolLightningErrorZ_ok(o);
10505         return (uint64_t)ret_conv;
10506 }
10507
10508 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
10509         LDKLightningError e_conv;
10510         e_conv.inner = (void*)(e & (~1));
10511         e_conv.is_owned = (e & 1) || (e == 0);
10512         e_conv = LightningError_clone(&e_conv);
10513         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10514         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
10515         return (uint64_t)ret_conv;
10516 }
10517
10518 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
10519         if ((_res & 1) != 0) return;
10520         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
10521         FREE((void*)_res);
10522         CResult_boolLightningErrorZ_free(_res_conv);
10523 }
10524
10525 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
10526         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
10527         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10528         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
10529         return (uint64_t)ret_conv;
10530 }
10531
10532 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
10533         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
10534         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10535         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
10536         return ((uint64_t)ret_conv);
10537 }
10538
10539 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
10540         LDKChannelAnnouncement a_conv;
10541         a_conv.inner = (void*)(a & (~1));
10542         a_conv.is_owned = (a & 1) || (a == 0);
10543         a_conv = ChannelAnnouncement_clone(&a_conv);
10544         LDKChannelUpdate b_conv;
10545         b_conv.inner = (void*)(b & (~1));
10546         b_conv.is_owned = (b & 1) || (b == 0);
10547         b_conv = ChannelUpdate_clone(&b_conv);
10548         LDKChannelUpdate c_conv;
10549         c_conv.inner = (void*)(c & (~1));
10550         c_conv.is_owned = (c & 1) || (c == 0);
10551         c_conv = ChannelUpdate_clone(&c_conv);
10552         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10553         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
10554         return ((uint64_t)ret_conv);
10555 }
10556
10557 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
10558         if ((_res & 1) != 0) return;
10559         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
10560         FREE((void*)_res);
10561         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
10562 }
10563
10564 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
10565         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
10566         _res_constr.datalen = *((uint32_t*)_res);
10567         if (_res_constr.datalen > 0)
10568                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10569         else
10570                 _res_constr.data = NULL;
10571         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10572         for (size_t h = 0; h < _res_constr.datalen; h++) {
10573                 uint32_t _res_conv_59 = _res_vals[h];
10574                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
10575                 FREE((void*)_res_conv_59);
10576                 _res_constr.data[h] = _res_conv_59_conv;
10577         }
10578         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
10579 }
10580
10581 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
10582         LDKCVec_NodeAnnouncementZ _res_constr;
10583         _res_constr.datalen = *((uint32_t*)_res);
10584         if (_res_constr.datalen > 0)
10585                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10586         else
10587                 _res_constr.data = NULL;
10588         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10589         for (size_t s = 0; s < _res_constr.datalen; s++) {
10590                 uint32_t _res_conv_18 = _res_vals[s];
10591                 LDKNodeAnnouncement _res_conv_18_conv;
10592                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
10593                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
10594                 _res_constr.data[s] = _res_conv_18_conv;
10595         }
10596         CVec_NodeAnnouncementZ_free(_res_constr);
10597 }
10598
10599 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
10600         LDKCVec_PublicKeyZ _res_constr;
10601         _res_constr.datalen = *((uint32_t*)_res);
10602         if (_res_constr.datalen > 0)
10603                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
10604         else
10605                 _res_constr.data = NULL;
10606         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10607         for (size_t m = 0; m < _res_constr.datalen; m++) {
10608                 int8_tArray _res_conv_12 = _res_vals[m];
10609                 LDKPublicKey _res_conv_12_ref;
10610                 CHECK(*((uint32_t*)_res_conv_12) == 33);
10611                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
10612                 _res_constr.data[m] = _res_conv_12_ref;
10613         }
10614         CVec_PublicKeyZ_free(_res_constr);
10615 }
10616
10617 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
10618         LDKCVec_u8Z o_ref;
10619         o_ref.datalen = *((uint32_t*)o);
10620         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
10621         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
10622         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10623         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
10624         return (uint64_t)ret_conv;
10625 }
10626
10627 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
10628         LDKPeerHandleError e_conv;
10629         e_conv.inner = (void*)(e & (~1));
10630         e_conv.is_owned = (e & 1) || (e == 0);
10631         e_conv = PeerHandleError_clone(&e_conv);
10632         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10633         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
10634         return (uint64_t)ret_conv;
10635 }
10636
10637 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
10638         if ((_res & 1) != 0) return;
10639         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10640         FREE((void*)_res);
10641         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
10642 }
10643
10644 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
10645         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
10646         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10647         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
10648         return (uint64_t)ret_conv;
10649 }
10650
10651 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
10652         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10653         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
10654         return (uint64_t)ret_conv;
10655 }
10656
10657 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
10658         LDKPeerHandleError e_conv;
10659         e_conv.inner = (void*)(e & (~1));
10660         e_conv.is_owned = (e & 1) || (e == 0);
10661         e_conv = PeerHandleError_clone(&e_conv);
10662         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10663         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
10664         return (uint64_t)ret_conv;
10665 }
10666
10667 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
10668         if ((_res & 1) != 0) return;
10669         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10670         FREE((void*)_res);
10671         CResult_NonePeerHandleErrorZ_free(_res_conv);
10672 }
10673
10674 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
10675         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
10676         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10677         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
10678         return (uint64_t)ret_conv;
10679 }
10680
10681 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
10682         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10683         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
10684         return (uint64_t)ret_conv;
10685 }
10686
10687 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
10688         LDKPeerHandleError e_conv;
10689         e_conv.inner = (void*)(e & (~1));
10690         e_conv.is_owned = (e & 1) || (e == 0);
10691         e_conv = PeerHandleError_clone(&e_conv);
10692         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10693         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
10694         return (uint64_t)ret_conv;
10695 }
10696
10697 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
10698         if ((_res & 1) != 0) return;
10699         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10700         FREE((void*)_res);
10701         CResult_boolPeerHandleErrorZ_free(_res_conv);
10702 }
10703
10704 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
10705         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
10706         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10707         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
10708         return (uint64_t)ret_conv;
10709 }
10710
10711 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
10712         LDKNodeId o_conv;
10713         o_conv.inner = (void*)(o & (~1));
10714         o_conv.is_owned = (o & 1) || (o == 0);
10715         o_conv = NodeId_clone(&o_conv);
10716         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
10717         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
10718         return (uint64_t)ret_conv;
10719 }
10720
10721 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
10722         LDKDecodeError e_conv;
10723         e_conv.inner = (void*)(e & (~1));
10724         e_conv.is_owned = (e & 1) || (e == 0);
10725         e_conv = DecodeError_clone(&e_conv);
10726         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
10727         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
10728         return (uint64_t)ret_conv;
10729 }
10730
10731 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
10732         if ((_res & 1) != 0) return;
10733         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(((uint64_t)_res) & ~1);
10734         FREE((void*)_res);
10735         CResult_NodeIdDecodeErrorZ_free(_res_conv);
10736 }
10737
10738 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
10739         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
10740         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
10741         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
10742         return (uint64_t)ret_conv;
10743 }
10744
10745 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
10746         LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
10747         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10748         *ret_copy = COption_AccessZ_some(o_conv);
10749         uint64_t ret_ref = (uint64_t)ret_copy;
10750         return ret_ref;
10751 }
10752
10753 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
10754         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10755         *ret_copy = COption_AccessZ_none();
10756         uint64_t ret_ref = (uint64_t)ret_copy;
10757         return ret_ref;
10758 }
10759
10760 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
10761         if ((_res & 1) != 0) return;
10762         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1);
10763         FREE((void*)_res);
10764         COption_AccessZ_free(_res_conv);
10765 }
10766
10767 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
10768         LDKDirectionalChannelInfo o_conv;
10769         o_conv.inner = (void*)(o & (~1));
10770         o_conv.is_owned = (o & 1) || (o == 0);
10771         o_conv = DirectionalChannelInfo_clone(&o_conv);
10772         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10773         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
10774         return (uint64_t)ret_conv;
10775 }
10776
10777 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
10778         LDKDecodeError e_conv;
10779         e_conv.inner = (void*)(e & (~1));
10780         e_conv.is_owned = (e & 1) || (e == 0);
10781         e_conv = DecodeError_clone(&e_conv);
10782         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10783         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
10784         return (uint64_t)ret_conv;
10785 }
10786
10787 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
10788         if ((_res & 1) != 0) return;
10789         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10790         FREE((void*)_res);
10791         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
10792 }
10793
10794 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10795         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
10796         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10797         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
10798         return (uint64_t)ret_conv;
10799 }
10800
10801 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
10802         LDKChannelInfo o_conv;
10803         o_conv.inner = (void*)(o & (~1));
10804         o_conv.is_owned = (o & 1) || (o == 0);
10805         o_conv = ChannelInfo_clone(&o_conv);
10806         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10807         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
10808         return (uint64_t)ret_conv;
10809 }
10810
10811 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
10812         LDKDecodeError e_conv;
10813         e_conv.inner = (void*)(e & (~1));
10814         e_conv.is_owned = (e & 1) || (e == 0);
10815         e_conv = DecodeError_clone(&e_conv);
10816         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10817         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
10818         return (uint64_t)ret_conv;
10819 }
10820
10821 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
10822         if ((_res & 1) != 0) return;
10823         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10824         FREE((void*)_res);
10825         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
10826 }
10827
10828 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10829         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
10830         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10831         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
10832         return (uint64_t)ret_conv;
10833 }
10834
10835 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
10836         LDKRoutingFees o_conv;
10837         o_conv.inner = (void*)(o & (~1));
10838         o_conv.is_owned = (o & 1) || (o == 0);
10839         o_conv = RoutingFees_clone(&o_conv);
10840         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10841         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
10842         return (uint64_t)ret_conv;
10843 }
10844
10845 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
10846         LDKDecodeError e_conv;
10847         e_conv.inner = (void*)(e & (~1));
10848         e_conv.is_owned = (e & 1) || (e == 0);
10849         e_conv = DecodeError_clone(&e_conv);
10850         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10851         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
10852         return (uint64_t)ret_conv;
10853 }
10854
10855 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
10856         if ((_res & 1) != 0) return;
10857         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10858         FREE((void*)_res);
10859         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
10860 }
10861
10862 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
10863         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
10864         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10865         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
10866         return (uint64_t)ret_conv;
10867 }
10868
10869 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
10870         LDKNodeAnnouncementInfo o_conv;
10871         o_conv.inner = (void*)(o & (~1));
10872         o_conv.is_owned = (o & 1) || (o == 0);
10873         o_conv = NodeAnnouncementInfo_clone(&o_conv);
10874         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10875         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
10876         return (uint64_t)ret_conv;
10877 }
10878
10879 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
10880         LDKDecodeError e_conv;
10881         e_conv.inner = (void*)(e & (~1));
10882         e_conv.is_owned = (e & 1) || (e == 0);
10883         e_conv = DecodeError_clone(&e_conv);
10884         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10885         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
10886         return (uint64_t)ret_conv;
10887 }
10888
10889 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
10890         if ((_res & 1) != 0) return;
10891         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10892         FREE((void*)_res);
10893         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
10894 }
10895
10896 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
10897         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
10898         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10899         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
10900         return (uint64_t)ret_conv;
10901 }
10902
10903 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
10904         LDKCVec_u64Z _res_constr;
10905         _res_constr.datalen = *((uint32_t*)_res);
10906         if (_res_constr.datalen > 0)
10907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10908         else
10909                 _res_constr.data = NULL;
10910         int64_t* _res_vals = (int64_t*)(_res + 4);
10911         for (size_t i = 0; i < _res_constr.datalen; i++) {
10912                 int64_t _res_conv_8 = _res_vals[i];
10913                 _res_constr.data[i] = _res_conv_8;
10914         }
10915         CVec_u64Z_free(_res_constr);
10916 }
10917
10918 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
10919         LDKNodeInfo o_conv;
10920         o_conv.inner = (void*)(o & (~1));
10921         o_conv.is_owned = (o & 1) || (o == 0);
10922         o_conv = NodeInfo_clone(&o_conv);
10923         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10924         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
10925         return (uint64_t)ret_conv;
10926 }
10927
10928 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
10929         LDKDecodeError e_conv;
10930         e_conv.inner = (void*)(e & (~1));
10931         e_conv.is_owned = (e & 1) || (e == 0);
10932         e_conv = DecodeError_clone(&e_conv);
10933         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10934         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
10935         return (uint64_t)ret_conv;
10936 }
10937
10938 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
10939         if ((_res & 1) != 0) return;
10940         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10941         FREE((void*)_res);
10942         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
10943 }
10944
10945 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
10946         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
10947         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10948         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
10949         return (uint64_t)ret_conv;
10950 }
10951
10952 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
10953         LDKNetworkGraph o_conv;
10954         o_conv.inner = (void*)(o & (~1));
10955         o_conv.is_owned = (o & 1) || (o == 0);
10956         o_conv = NetworkGraph_clone(&o_conv);
10957         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10958         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
10959         return (uint64_t)ret_conv;
10960 }
10961
10962 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
10963         LDKDecodeError e_conv;
10964         e_conv.inner = (void*)(e & (~1));
10965         e_conv.is_owned = (e & 1) || (e == 0);
10966         e_conv = DecodeError_clone(&e_conv);
10967         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10968         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
10969         return (uint64_t)ret_conv;
10970 }
10971
10972 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
10973         if ((_res & 1) != 0) return;
10974         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
10975         FREE((void*)_res);
10976         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
10977 }
10978
10979 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
10980         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
10981         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10982         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
10983         return (uint64_t)ret_conv;
10984 }
10985
10986 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
10987         LDKCVec_NetAddressZ o_constr;
10988         o_constr.datalen = *((uint32_t*)o);
10989         if (o_constr.datalen > 0)
10990                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10991         else
10992                 o_constr.data = NULL;
10993         uint32_t* o_vals = (uint32_t*)(o + 4);
10994         for (size_t m = 0; m < o_constr.datalen; m++) {
10995                 uint32_t o_conv_12 = o_vals[m];
10996                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(((uint64_t)o_conv_12) & ~1);
10997                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
10998                 o_constr.data[m] = o_conv_12_conv;
10999         }
11000         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
11001         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
11002         uint64_t ret_ref = (uint64_t)ret_copy;
11003         return ret_ref;
11004 }
11005
11006 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_none() {
11007         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
11008         *ret_copy = COption_CVec_NetAddressZZ_none();
11009         uint64_t ret_ref = (uint64_t)ret_copy;
11010         return ret_ref;
11011 }
11012
11013 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
11014         if ((_res & 1) != 0) return;
11015         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(((uint64_t)_res) & ~1);
11016         FREE((void*)_res);
11017         COption_CVec_NetAddressZZ_free(_res_conv);
11018 }
11019
11020 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
11021         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
11022         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
11023         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
11024         uint64_t ret_ref = (uint64_t)ret_copy;
11025         return ret_ref;
11026 }
11027
11028 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
11029         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11030         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
11031         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11032         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
11033         return (uint64_t)ret_conv;
11034 }
11035
11036 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
11037         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11038         *ret_conv = CResult_NetAddressu8Z_err(e);
11039         return (uint64_t)ret_conv;
11040 }
11041
11042 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
11043         if ((_res & 1) != 0) return;
11044         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
11045         FREE((void*)_res);
11046         CResult_NetAddressu8Z_free(_res_conv);
11047 }
11048
11049 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
11050         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
11051         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
11052         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
11053         return (uint64_t)ret_conv;
11054 }
11055
11056 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
11057         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
11058         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
11059         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11060         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
11061         return (uint64_t)ret_conv;
11062 }
11063
11064 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
11065         LDKDecodeError e_conv;
11066         e_conv.inner = (void*)(e & (~1));
11067         e_conv.is_owned = (e & 1) || (e == 0);
11068         e_conv = DecodeError_clone(&e_conv);
11069         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11070         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
11071         return (uint64_t)ret_conv;
11072 }
11073
11074 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
11075         if ((_res & 1) != 0) return;
11076         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11077         FREE((void*)_res);
11078         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
11079 }
11080
11081 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
11082         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
11083         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
11084         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
11085         return (uint64_t)ret_conv;
11086 }
11087
11088 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
11089         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
11090         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
11091         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11092         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
11093         return (uint64_t)ret_conv;
11094 }
11095
11096 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
11097         LDKDecodeError e_conv;
11098         e_conv.inner = (void*)(e & (~1));
11099         e_conv.is_owned = (e & 1) || (e == 0);
11100         e_conv = DecodeError_clone(&e_conv);
11101         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11102         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
11103         return (uint64_t)ret_conv;
11104 }
11105
11106 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
11107         if ((_res & 1) != 0) return;
11108         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
11109         FREE((void*)_res);
11110         CResult_NetAddressDecodeErrorZ_free(_res_conv);
11111 }
11112
11113 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
11114         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
11115         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
11116         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
11117         return (uint64_t)ret_conv;
11118 }
11119
11120 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
11121         LDKCVec_UpdateAddHTLCZ _res_constr;
11122         _res_constr.datalen = *((uint32_t*)_res);
11123         if (_res_constr.datalen > 0)
11124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11125         else
11126                 _res_constr.data = NULL;
11127         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11128         for (size_t p = 0; p < _res_constr.datalen; p++) {
11129                 uint32_t _res_conv_15 = _res_vals[p];
11130                 LDKUpdateAddHTLC _res_conv_15_conv;
11131                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
11132                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
11133                 _res_constr.data[p] = _res_conv_15_conv;
11134         }
11135         CVec_UpdateAddHTLCZ_free(_res_constr);
11136 }
11137
11138 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
11139         LDKCVec_UpdateFulfillHTLCZ _res_constr;
11140         _res_constr.datalen = *((uint32_t*)_res);
11141         if (_res_constr.datalen > 0)
11142                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11143         else
11144                 _res_constr.data = NULL;
11145         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11146         for (size_t t = 0; t < _res_constr.datalen; t++) {
11147                 uint32_t _res_conv_19 = _res_vals[t];
11148                 LDKUpdateFulfillHTLC _res_conv_19_conv;
11149                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
11150                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
11151                 _res_constr.data[t] = _res_conv_19_conv;
11152         }
11153         CVec_UpdateFulfillHTLCZ_free(_res_constr);
11154 }
11155
11156 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
11157         LDKCVec_UpdateFailHTLCZ _res_constr;
11158         _res_constr.datalen = *((uint32_t*)_res);
11159         if (_res_constr.datalen > 0)
11160                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11161         else
11162                 _res_constr.data = NULL;
11163         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11164         for (size_t q = 0; q < _res_constr.datalen; q++) {
11165                 uint32_t _res_conv_16 = _res_vals[q];
11166                 LDKUpdateFailHTLC _res_conv_16_conv;
11167                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11168                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11169                 _res_constr.data[q] = _res_conv_16_conv;
11170         }
11171         CVec_UpdateFailHTLCZ_free(_res_constr);
11172 }
11173
11174 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
11175         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
11176         _res_constr.datalen = *((uint32_t*)_res);
11177         if (_res_constr.datalen > 0)
11178                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11179         else
11180                 _res_constr.data = NULL;
11181         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11182         for (size_t z = 0; z < _res_constr.datalen; z++) {
11183                 uint32_t _res_conv_25 = _res_vals[z];
11184                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
11185                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
11186                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
11187                 _res_constr.data[z] = _res_conv_25_conv;
11188         }
11189         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
11190 }
11191
11192 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
11193         LDKAcceptChannel o_conv;
11194         o_conv.inner = (void*)(o & (~1));
11195         o_conv.is_owned = (o & 1) || (o == 0);
11196         o_conv = AcceptChannel_clone(&o_conv);
11197         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11198         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
11199         return (uint64_t)ret_conv;
11200 }
11201
11202 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
11203         LDKDecodeError e_conv;
11204         e_conv.inner = (void*)(e & (~1));
11205         e_conv.is_owned = (e & 1) || (e == 0);
11206         e_conv = DecodeError_clone(&e_conv);
11207         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11208         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
11209         return (uint64_t)ret_conv;
11210 }
11211
11212 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
11213         if ((_res & 1) != 0) return;
11214         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11215         FREE((void*)_res);
11216         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
11217 }
11218
11219 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
11220         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
11221         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
11222         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
11223         return (uint64_t)ret_conv;
11224 }
11225
11226 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
11227         LDKAnnouncementSignatures o_conv;
11228         o_conv.inner = (void*)(o & (~1));
11229         o_conv.is_owned = (o & 1) || (o == 0);
11230         o_conv = AnnouncementSignatures_clone(&o_conv);
11231         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11232         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
11233         return (uint64_t)ret_conv;
11234 }
11235
11236 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
11237         LDKDecodeError e_conv;
11238         e_conv.inner = (void*)(e & (~1));
11239         e_conv.is_owned = (e & 1) || (e == 0);
11240         e_conv = DecodeError_clone(&e_conv);
11241         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11242         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
11243         return (uint64_t)ret_conv;
11244 }
11245
11246 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
11247         if ((_res & 1) != 0) return;
11248         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11249         FREE((void*)_res);
11250         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
11251 }
11252
11253 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
11254         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
11255         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
11256         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
11257         return (uint64_t)ret_conv;
11258 }
11259
11260 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
11261         LDKChannelReestablish o_conv;
11262         o_conv.inner = (void*)(o & (~1));
11263         o_conv.is_owned = (o & 1) || (o == 0);
11264         o_conv = ChannelReestablish_clone(&o_conv);
11265         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11266         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
11267         return (uint64_t)ret_conv;
11268 }
11269
11270 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
11271         LDKDecodeError e_conv;
11272         e_conv.inner = (void*)(e & (~1));
11273         e_conv.is_owned = (e & 1) || (e == 0);
11274         e_conv = DecodeError_clone(&e_conv);
11275         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11276         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
11277         return (uint64_t)ret_conv;
11278 }
11279
11280 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
11281         if ((_res & 1) != 0) return;
11282         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
11283         FREE((void*)_res);
11284         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
11285 }
11286
11287 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
11288         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
11289         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11290         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
11291         return (uint64_t)ret_conv;
11292 }
11293
11294 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
11295         LDKClosingSigned o_conv;
11296         o_conv.inner = (void*)(o & (~1));
11297         o_conv.is_owned = (o & 1) || (o == 0);
11298         o_conv = ClosingSigned_clone(&o_conv);
11299         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11300         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
11301         return (uint64_t)ret_conv;
11302 }
11303
11304 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
11305         LDKDecodeError e_conv;
11306         e_conv.inner = (void*)(e & (~1));
11307         e_conv.is_owned = (e & 1) || (e == 0);
11308         e_conv = DecodeError_clone(&e_conv);
11309         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11310         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
11311         return (uint64_t)ret_conv;
11312 }
11313
11314 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
11315         if ((_res & 1) != 0) return;
11316         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11317         FREE((void*)_res);
11318         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
11319 }
11320
11321 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
11322         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
11323         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
11324         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
11325         return (uint64_t)ret_conv;
11326 }
11327
11328 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
11329         LDKClosingSignedFeeRange o_conv;
11330         o_conv.inner = (void*)(o & (~1));
11331         o_conv.is_owned = (o & 1) || (o == 0);
11332         o_conv = ClosingSignedFeeRange_clone(&o_conv);
11333         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
11334         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
11335         return (uint64_t)ret_conv;
11336 }
11337
11338 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
11339         LDKDecodeError e_conv;
11340         e_conv.inner = (void*)(e & (~1));
11341         e_conv.is_owned = (e & 1) || (e == 0);
11342         e_conv = DecodeError_clone(&e_conv);
11343         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
11344         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
11345         return (uint64_t)ret_conv;
11346 }
11347
11348 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
11349         if ((_res & 1) != 0) return;
11350         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11351         FREE((void*)_res);
11352         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
11353 }
11354
11355 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
11356         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
11357         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
11358         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
11359         return (uint64_t)ret_conv;
11360 }
11361
11362 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
11363         LDKCommitmentSigned o_conv;
11364         o_conv.inner = (void*)(o & (~1));
11365         o_conv.is_owned = (o & 1) || (o == 0);
11366         o_conv = CommitmentSigned_clone(&o_conv);
11367         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11368         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
11369         return (uint64_t)ret_conv;
11370 }
11371
11372 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
11373         LDKDecodeError e_conv;
11374         e_conv.inner = (void*)(e & (~1));
11375         e_conv.is_owned = (e & 1) || (e == 0);
11376         e_conv = DecodeError_clone(&e_conv);
11377         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11378         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
11379         return (uint64_t)ret_conv;
11380 }
11381
11382 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
11383         if ((_res & 1) != 0) return;
11384         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11385         FREE((void*)_res);
11386         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
11387 }
11388
11389 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
11390         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
11391         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
11392         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
11393         return (uint64_t)ret_conv;
11394 }
11395
11396 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
11397         LDKFundingCreated o_conv;
11398         o_conv.inner = (void*)(o & (~1));
11399         o_conv.is_owned = (o & 1) || (o == 0);
11400         o_conv = FundingCreated_clone(&o_conv);
11401         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11402         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
11403         return (uint64_t)ret_conv;
11404 }
11405
11406 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
11407         LDKDecodeError e_conv;
11408         e_conv.inner = (void*)(e & (~1));
11409         e_conv.is_owned = (e & 1) || (e == 0);
11410         e_conv = DecodeError_clone(&e_conv);
11411         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11412         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
11413         return (uint64_t)ret_conv;
11414 }
11415
11416 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
11417         if ((_res & 1) != 0) return;
11418         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11419         FREE((void*)_res);
11420         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
11421 }
11422
11423 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
11424         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
11425         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
11426         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
11427         return (uint64_t)ret_conv;
11428 }
11429
11430 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
11431         LDKFundingSigned o_conv;
11432         o_conv.inner = (void*)(o & (~1));
11433         o_conv.is_owned = (o & 1) || (o == 0);
11434         o_conv = FundingSigned_clone(&o_conv);
11435         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11436         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
11437         return (uint64_t)ret_conv;
11438 }
11439
11440 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
11441         LDKDecodeError e_conv;
11442         e_conv.inner = (void*)(e & (~1));
11443         e_conv.is_owned = (e & 1) || (e == 0);
11444         e_conv = DecodeError_clone(&e_conv);
11445         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11446         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
11447         return (uint64_t)ret_conv;
11448 }
11449
11450 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
11451         if ((_res & 1) != 0) return;
11452         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11453         FREE((void*)_res);
11454         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
11455 }
11456
11457 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
11458         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
11459         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11460         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
11461         return (uint64_t)ret_conv;
11462 }
11463
11464 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
11465         LDKFundingLocked o_conv;
11466         o_conv.inner = (void*)(o & (~1));
11467         o_conv.is_owned = (o & 1) || (o == 0);
11468         o_conv = FundingLocked_clone(&o_conv);
11469         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11470         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
11471         return (uint64_t)ret_conv;
11472 }
11473
11474 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
11475         LDKDecodeError e_conv;
11476         e_conv.inner = (void*)(e & (~1));
11477         e_conv.is_owned = (e & 1) || (e == 0);
11478         e_conv = DecodeError_clone(&e_conv);
11479         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11480         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
11481         return (uint64_t)ret_conv;
11482 }
11483
11484 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
11485         if ((_res & 1) != 0) return;
11486         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11487         FREE((void*)_res);
11488         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
11489 }
11490
11491 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
11492         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
11493         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11494         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
11495         return (uint64_t)ret_conv;
11496 }
11497
11498 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
11499         LDKInit o_conv;
11500         o_conv.inner = (void*)(o & (~1));
11501         o_conv.is_owned = (o & 1) || (o == 0);
11502         o_conv = Init_clone(&o_conv);
11503         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11504         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
11505         return (uint64_t)ret_conv;
11506 }
11507
11508 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
11509         LDKDecodeError e_conv;
11510         e_conv.inner = (void*)(e & (~1));
11511         e_conv.is_owned = (e & 1) || (e == 0);
11512         e_conv = DecodeError_clone(&e_conv);
11513         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11514         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
11515         return (uint64_t)ret_conv;
11516 }
11517
11518 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
11519         if ((_res & 1) != 0) return;
11520         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
11521         FREE((void*)_res);
11522         CResult_InitDecodeErrorZ_free(_res_conv);
11523 }
11524
11525 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
11526         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
11527         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11528         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
11529         return (uint64_t)ret_conv;
11530 }
11531
11532 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
11533         LDKOpenChannel o_conv;
11534         o_conv.inner = (void*)(o & (~1));
11535         o_conv.is_owned = (o & 1) || (o == 0);
11536         o_conv = OpenChannel_clone(&o_conv);
11537         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11538         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
11539         return (uint64_t)ret_conv;
11540 }
11541
11542 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
11543         LDKDecodeError e_conv;
11544         e_conv.inner = (void*)(e & (~1));
11545         e_conv.is_owned = (e & 1) || (e == 0);
11546         e_conv = DecodeError_clone(&e_conv);
11547         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11548         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
11549         return (uint64_t)ret_conv;
11550 }
11551
11552 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
11553         if ((_res & 1) != 0) return;
11554         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11555         FREE((void*)_res);
11556         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
11557 }
11558
11559 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
11560         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
11561         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11562         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
11563         return (uint64_t)ret_conv;
11564 }
11565
11566 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
11567         LDKRevokeAndACK o_conv;
11568         o_conv.inner = (void*)(o & (~1));
11569         o_conv.is_owned = (o & 1) || (o == 0);
11570         o_conv = RevokeAndACK_clone(&o_conv);
11571         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11572         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
11573         return (uint64_t)ret_conv;
11574 }
11575
11576 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
11577         LDKDecodeError e_conv;
11578         e_conv.inner = (void*)(e & (~1));
11579         e_conv.is_owned = (e & 1) || (e == 0);
11580         e_conv = DecodeError_clone(&e_conv);
11581         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11582         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
11583         return (uint64_t)ret_conv;
11584 }
11585
11586 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
11587         if ((_res & 1) != 0) return;
11588         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
11589         FREE((void*)_res);
11590         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
11591 }
11592
11593 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
11594         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
11595         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11596         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
11597         return (uint64_t)ret_conv;
11598 }
11599
11600 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
11601         LDKShutdown o_conv;
11602         o_conv.inner = (void*)(o & (~1));
11603         o_conv.is_owned = (o & 1) || (o == 0);
11604         o_conv = Shutdown_clone(&o_conv);
11605         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11606         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
11607         return (uint64_t)ret_conv;
11608 }
11609
11610 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
11611         LDKDecodeError e_conv;
11612         e_conv.inner = (void*)(e & (~1));
11613         e_conv.is_owned = (e & 1) || (e == 0);
11614         e_conv = DecodeError_clone(&e_conv);
11615         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11616         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
11617         return (uint64_t)ret_conv;
11618 }
11619
11620 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
11621         if ((_res & 1) != 0) return;
11622         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
11623         FREE((void*)_res);
11624         CResult_ShutdownDecodeErrorZ_free(_res_conv);
11625 }
11626
11627 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
11628         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
11629         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11630         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
11631         return (uint64_t)ret_conv;
11632 }
11633
11634 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
11635         LDKUpdateFailHTLC o_conv;
11636         o_conv.inner = (void*)(o & (~1));
11637         o_conv.is_owned = (o & 1) || (o == 0);
11638         o_conv = UpdateFailHTLC_clone(&o_conv);
11639         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11640         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
11641         return (uint64_t)ret_conv;
11642 }
11643
11644 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
11645         LDKDecodeError e_conv;
11646         e_conv.inner = (void*)(e & (~1));
11647         e_conv.is_owned = (e & 1) || (e == 0);
11648         e_conv = DecodeError_clone(&e_conv);
11649         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11650         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
11651         return (uint64_t)ret_conv;
11652 }
11653
11654 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
11655         if ((_res & 1) != 0) return;
11656         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11657         FREE((void*)_res);
11658         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
11659 }
11660
11661 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
11662         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
11663         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11664         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
11665         return (uint64_t)ret_conv;
11666 }
11667
11668 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
11669         LDKUpdateFailMalformedHTLC o_conv;
11670         o_conv.inner = (void*)(o & (~1));
11671         o_conv.is_owned = (o & 1) || (o == 0);
11672         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
11673         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11674         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
11675         return (uint64_t)ret_conv;
11676 }
11677
11678 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
11679         LDKDecodeError e_conv;
11680         e_conv.inner = (void*)(e & (~1));
11681         e_conv.is_owned = (e & 1) || (e == 0);
11682         e_conv = DecodeError_clone(&e_conv);
11683         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11684         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
11685         return (uint64_t)ret_conv;
11686 }
11687
11688 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
11689         if ((_res & 1) != 0) return;
11690         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11691         FREE((void*)_res);
11692         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
11693 }
11694
11695 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
11696         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
11697         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11698         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
11699         return (uint64_t)ret_conv;
11700 }
11701
11702 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
11703         LDKUpdateFee o_conv;
11704         o_conv.inner = (void*)(o & (~1));
11705         o_conv.is_owned = (o & 1) || (o == 0);
11706         o_conv = UpdateFee_clone(&o_conv);
11707         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11708         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
11709         return (uint64_t)ret_conv;
11710 }
11711
11712 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
11713         LDKDecodeError e_conv;
11714         e_conv.inner = (void*)(e & (~1));
11715         e_conv.is_owned = (e & 1) || (e == 0);
11716         e_conv = DecodeError_clone(&e_conv);
11717         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11718         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
11719         return (uint64_t)ret_conv;
11720 }
11721
11722 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
11723         if ((_res & 1) != 0) return;
11724         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11725         FREE((void*)_res);
11726         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
11727 }
11728
11729 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
11730         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
11731         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11732         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
11733         return (uint64_t)ret_conv;
11734 }
11735
11736 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
11737         LDKUpdateFulfillHTLC o_conv;
11738         o_conv.inner = (void*)(o & (~1));
11739         o_conv.is_owned = (o & 1) || (o == 0);
11740         o_conv = UpdateFulfillHTLC_clone(&o_conv);
11741         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11742         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
11743         return (uint64_t)ret_conv;
11744 }
11745
11746 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
11747         LDKDecodeError e_conv;
11748         e_conv.inner = (void*)(e & (~1));
11749         e_conv.is_owned = (e & 1) || (e == 0);
11750         e_conv = DecodeError_clone(&e_conv);
11751         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11752         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
11753         return (uint64_t)ret_conv;
11754 }
11755
11756 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
11757         if ((_res & 1) != 0) return;
11758         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11759         FREE((void*)_res);
11760         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
11761 }
11762
11763 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
11764         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
11765         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11766         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
11767         return (uint64_t)ret_conv;
11768 }
11769
11770 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
11771         LDKUpdateAddHTLC o_conv;
11772         o_conv.inner = (void*)(o & (~1));
11773         o_conv.is_owned = (o & 1) || (o == 0);
11774         o_conv = UpdateAddHTLC_clone(&o_conv);
11775         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11776         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
11777         return (uint64_t)ret_conv;
11778 }
11779
11780 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
11781         LDKDecodeError e_conv;
11782         e_conv.inner = (void*)(e & (~1));
11783         e_conv.is_owned = (e & 1) || (e == 0);
11784         e_conv = DecodeError_clone(&e_conv);
11785         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11786         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
11787         return (uint64_t)ret_conv;
11788 }
11789
11790 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
11791         if ((_res & 1) != 0) return;
11792         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11793         FREE((void*)_res);
11794         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
11795 }
11796
11797 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
11798         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
11799         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11800         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
11801         return (uint64_t)ret_conv;
11802 }
11803
11804 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
11805         LDKPing o_conv;
11806         o_conv.inner = (void*)(o & (~1));
11807         o_conv.is_owned = (o & 1) || (o == 0);
11808         o_conv = Ping_clone(&o_conv);
11809         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11810         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
11811         return (uint64_t)ret_conv;
11812 }
11813
11814 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
11815         LDKDecodeError e_conv;
11816         e_conv.inner = (void*)(e & (~1));
11817         e_conv.is_owned = (e & 1) || (e == 0);
11818         e_conv = DecodeError_clone(&e_conv);
11819         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11820         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
11821         return (uint64_t)ret_conv;
11822 }
11823
11824 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
11825         if ((_res & 1) != 0) return;
11826         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
11827         FREE((void*)_res);
11828         CResult_PingDecodeErrorZ_free(_res_conv);
11829 }
11830
11831 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
11832         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
11833         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11834         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
11835         return (uint64_t)ret_conv;
11836 }
11837
11838 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
11839         LDKPong o_conv;
11840         o_conv.inner = (void*)(o & (~1));
11841         o_conv.is_owned = (o & 1) || (o == 0);
11842         o_conv = Pong_clone(&o_conv);
11843         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11844         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
11845         return (uint64_t)ret_conv;
11846 }
11847
11848 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
11849         LDKDecodeError e_conv;
11850         e_conv.inner = (void*)(e & (~1));
11851         e_conv.is_owned = (e & 1) || (e == 0);
11852         e_conv = DecodeError_clone(&e_conv);
11853         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11854         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
11855         return (uint64_t)ret_conv;
11856 }
11857
11858 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
11859         if ((_res & 1) != 0) return;
11860         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
11861         FREE((void*)_res);
11862         CResult_PongDecodeErrorZ_free(_res_conv);
11863 }
11864
11865 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
11866         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
11867         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11868         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
11869         return (uint64_t)ret_conv;
11870 }
11871
11872 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11873         LDKUnsignedChannelAnnouncement o_conv;
11874         o_conv.inner = (void*)(o & (~1));
11875         o_conv.is_owned = (o & 1) || (o == 0);
11876         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
11877         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11878         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
11879         return (uint64_t)ret_conv;
11880 }
11881
11882 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11883         LDKDecodeError e_conv;
11884         e_conv.inner = (void*)(e & (~1));
11885         e_conv.is_owned = (e & 1) || (e == 0);
11886         e_conv = DecodeError_clone(&e_conv);
11887         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11888         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
11889         return (uint64_t)ret_conv;
11890 }
11891
11892 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11893         if ((_res & 1) != 0) return;
11894         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11895         FREE((void*)_res);
11896         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
11897 }
11898
11899 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11900         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11901         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11902         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11903         return (uint64_t)ret_conv;
11904 }
11905
11906 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11907         LDKChannelAnnouncement o_conv;
11908         o_conv.inner = (void*)(o & (~1));
11909         o_conv.is_owned = (o & 1) || (o == 0);
11910         o_conv = ChannelAnnouncement_clone(&o_conv);
11911         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11912         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
11913         return (uint64_t)ret_conv;
11914 }
11915
11916 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11917         LDKDecodeError e_conv;
11918         e_conv.inner = (void*)(e & (~1));
11919         e_conv.is_owned = (e & 1) || (e == 0);
11920         e_conv = DecodeError_clone(&e_conv);
11921         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11922         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
11923         return (uint64_t)ret_conv;
11924 }
11925
11926 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11927         if ((_res & 1) != 0) return;
11928         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11929         FREE((void*)_res);
11930         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
11931 }
11932
11933 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11934         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11935         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11936         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11937         return (uint64_t)ret_conv;
11938 }
11939
11940 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11941         LDKUnsignedChannelUpdate o_conv;
11942         o_conv.inner = (void*)(o & (~1));
11943         o_conv.is_owned = (o & 1) || (o == 0);
11944         o_conv = UnsignedChannelUpdate_clone(&o_conv);
11945         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11946         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
11947         return (uint64_t)ret_conv;
11948 }
11949
11950 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
11951         LDKDecodeError e_conv;
11952         e_conv.inner = (void*)(e & (~1));
11953         e_conv.is_owned = (e & 1) || (e == 0);
11954         e_conv = DecodeError_clone(&e_conv);
11955         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11956         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
11957         return (uint64_t)ret_conv;
11958 }
11959
11960 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11961         if ((_res & 1) != 0) return;
11962         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11963         FREE((void*)_res);
11964         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
11965 }
11966
11967 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
11968         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
11969         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11970         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
11971         return (uint64_t)ret_conv;
11972 }
11973
11974 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11975         LDKChannelUpdate o_conv;
11976         o_conv.inner = (void*)(o & (~1));
11977         o_conv.is_owned = (o & 1) || (o == 0);
11978         o_conv = ChannelUpdate_clone(&o_conv);
11979         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11980         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
11981         return (uint64_t)ret_conv;
11982 }
11983
11984 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
11985         LDKDecodeError e_conv;
11986         e_conv.inner = (void*)(e & (~1));
11987         e_conv.is_owned = (e & 1) || (e == 0);
11988         e_conv = DecodeError_clone(&e_conv);
11989         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11990         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11995         if ((_res & 1) != 0) return;
11996         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11997         FREE((void*)_res);
11998         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
11999 }
12000
12001 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
12002         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12003         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12004         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12005         return (uint64_t)ret_conv;
12006 }
12007
12008 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
12009         LDKErrorMessage o_conv;
12010         o_conv.inner = (void*)(o & (~1));
12011         o_conv.is_owned = (o & 1) || (o == 0);
12012         o_conv = ErrorMessage_clone(&o_conv);
12013         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12014         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12015         return (uint64_t)ret_conv;
12016 }
12017
12018 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
12019         LDKDecodeError e_conv;
12020         e_conv.inner = (void*)(e & (~1));
12021         e_conv.is_owned = (e & 1) || (e == 0);
12022         e_conv = DecodeError_clone(&e_conv);
12023         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12024         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12025         return (uint64_t)ret_conv;
12026 }
12027
12028 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
12029         if ((_res & 1) != 0) return;
12030         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12031         FREE((void*)_res);
12032         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12033 }
12034
12035 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
12036         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
12037         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12038         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
12039         return (uint64_t)ret_conv;
12040 }
12041
12042 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
12043         LDKUnsignedNodeAnnouncement o_conv;
12044         o_conv.inner = (void*)(o & (~1));
12045         o_conv.is_owned = (o & 1) || (o == 0);
12046         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
12047         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12048         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
12049         return (uint64_t)ret_conv;
12050 }
12051
12052 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
12053         LDKDecodeError e_conv;
12054         e_conv.inner = (void*)(e & (~1));
12055         e_conv.is_owned = (e & 1) || (e == 0);
12056         e_conv = DecodeError_clone(&e_conv);
12057         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12058         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
12059         return (uint64_t)ret_conv;
12060 }
12061
12062 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
12063         if ((_res & 1) != 0) return;
12064         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12065         FREE((void*)_res);
12066         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
12067 }
12068
12069 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
12070         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
12071         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12072         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
12073         return (uint64_t)ret_conv;
12074 }
12075
12076 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
12077         LDKNodeAnnouncement o_conv;
12078         o_conv.inner = (void*)(o & (~1));
12079         o_conv.is_owned = (o & 1) || (o == 0);
12080         o_conv = NodeAnnouncement_clone(&o_conv);
12081         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12082         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
12083         return (uint64_t)ret_conv;
12084 }
12085
12086 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
12087         LDKDecodeError e_conv;
12088         e_conv.inner = (void*)(e & (~1));
12089         e_conv.is_owned = (e & 1) || (e == 0);
12090         e_conv = DecodeError_clone(&e_conv);
12091         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12092         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
12093         return (uint64_t)ret_conv;
12094 }
12095
12096 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
12097         if ((_res & 1) != 0) return;
12098         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12099         FREE((void*)_res);
12100         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
12101 }
12102
12103 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
12104         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
12105         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
12106         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
12107         return (uint64_t)ret_conv;
12108 }
12109
12110 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
12111         LDKQueryShortChannelIds o_conv;
12112         o_conv.inner = (void*)(o & (~1));
12113         o_conv.is_owned = (o & 1) || (o == 0);
12114         o_conv = QueryShortChannelIds_clone(&o_conv);
12115         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12116         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
12117         return (uint64_t)ret_conv;
12118 }
12119
12120 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
12121         LDKDecodeError e_conv;
12122         e_conv.inner = (void*)(e & (~1));
12123         e_conv.is_owned = (e & 1) || (e == 0);
12124         e_conv = DecodeError_clone(&e_conv);
12125         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12126         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
12127         return (uint64_t)ret_conv;
12128 }
12129
12130 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
12131         if ((_res & 1) != 0) return;
12132         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
12133         FREE((void*)_res);
12134         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
12135 }
12136
12137 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
12138         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
12139         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12140         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
12141         return (uint64_t)ret_conv;
12142 }
12143
12144 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
12145         LDKReplyShortChannelIdsEnd o_conv;
12146         o_conv.inner = (void*)(o & (~1));
12147         o_conv.is_owned = (o & 1) || (o == 0);
12148         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
12149         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12150         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
12151         return (uint64_t)ret_conv;
12152 }
12153
12154 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
12155         LDKDecodeError e_conv;
12156         e_conv.inner = (void*)(e & (~1));
12157         e_conv.is_owned = (e & 1) || (e == 0);
12158         e_conv = DecodeError_clone(&e_conv);
12159         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12160         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
12161         return (uint64_t)ret_conv;
12162 }
12163
12164 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
12165         if ((_res & 1) != 0) return;
12166         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
12167         FREE((void*)_res);
12168         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
12169 }
12170
12171 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
12172         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
12173         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12174         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
12175         return (uint64_t)ret_conv;
12176 }
12177
12178 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
12179         LDKQueryChannelRange o_conv;
12180         o_conv.inner = (void*)(o & (~1));
12181         o_conv.is_owned = (o & 1) || (o == 0);
12182         o_conv = QueryChannelRange_clone(&o_conv);
12183         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12184         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
12185         return (uint64_t)ret_conv;
12186 }
12187
12188 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
12189         LDKDecodeError e_conv;
12190         e_conv.inner = (void*)(e & (~1));
12191         e_conv.is_owned = (e & 1) || (e == 0);
12192         e_conv = DecodeError_clone(&e_conv);
12193         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12194         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
12195         return (uint64_t)ret_conv;
12196 }
12197
12198 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
12199         if ((_res & 1) != 0) return;
12200         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12201         FREE((void*)_res);
12202         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
12203 }
12204
12205 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
12206         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
12207         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12208         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
12209         return (uint64_t)ret_conv;
12210 }
12211
12212 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
12213         LDKReplyChannelRange o_conv;
12214         o_conv.inner = (void*)(o & (~1));
12215         o_conv.is_owned = (o & 1) || (o == 0);
12216         o_conv = ReplyChannelRange_clone(&o_conv);
12217         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12218         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
12219         return (uint64_t)ret_conv;
12220 }
12221
12222 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
12223         LDKDecodeError e_conv;
12224         e_conv.inner = (void*)(e & (~1));
12225         e_conv.is_owned = (e & 1) || (e == 0);
12226         e_conv = DecodeError_clone(&e_conv);
12227         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12228         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
12229         return (uint64_t)ret_conv;
12230 }
12231
12232 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
12233         if ((_res & 1) != 0) return;
12234         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12235         FREE((void*)_res);
12236         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
12237 }
12238
12239 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
12240         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
12241         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12242         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
12243         return (uint64_t)ret_conv;
12244 }
12245
12246 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
12247         LDKGossipTimestampFilter o_conv;
12248         o_conv.inner = (void*)(o & (~1));
12249         o_conv.is_owned = (o & 1) || (o == 0);
12250         o_conv = GossipTimestampFilter_clone(&o_conv);
12251         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12252         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
12253         return (uint64_t)ret_conv;
12254 }
12255
12256 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
12257         LDKDecodeError e_conv;
12258         e_conv.inner = (void*)(e & (~1));
12259         e_conv.is_owned = (e & 1) || (e == 0);
12260         e_conv = DecodeError_clone(&e_conv);
12261         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12262         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
12263         return (uint64_t)ret_conv;
12264 }
12265
12266 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
12267         if ((_res & 1) != 0) return;
12268         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
12269         FREE((void*)_res);
12270         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
12271 }
12272
12273 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
12274         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
12275         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12276         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
12277         return (uint64_t)ret_conv;
12278 }
12279
12280 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
12281         LDKInvoice o_conv;
12282         o_conv.inner = (void*)(o & (~1));
12283         o_conv.is_owned = (o & 1) || (o == 0);
12284         o_conv = Invoice_clone(&o_conv);
12285         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12286         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
12287         return (uint64_t)ret_conv;
12288 }
12289
12290 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
12291         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
12292         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
12293         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12294         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
12295         return (uint64_t)ret_conv;
12296 }
12297
12298 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
12299         if ((_res & 1) != 0) return;
12300         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
12301         FREE((void*)_res);
12302         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
12303 }
12304
12305 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
12306         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
12307         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
12308         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
12309         return (uint64_t)ret_conv;
12310 }
12311
12312 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
12313         LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
12314         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
12315         *ret_copy = COption_FilterZ_some(o_conv);
12316         uint64_t ret_ref = (uint64_t)ret_copy;
12317         return ret_ref;
12318 }
12319
12320 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
12321         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
12322         *ret_copy = COption_FilterZ_none();
12323         uint64_t ret_ref = (uint64_t)ret_copy;
12324         return ret_ref;
12325 }
12326
12327 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
12328         if ((_res & 1) != 0) return;
12329         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1);
12330         FREE((void*)_res);
12331         COption_FilterZ_free(_res_conv);
12332 }
12333
12334 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
12335         LDKLockedChannelMonitor o_conv;
12336         o_conv.inner = (void*)(o & (~1));
12337         o_conv.is_owned = (o & 1) || (o == 0);
12338         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
12339         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
12340         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
12341         return (uint64_t)ret_conv;
12342 }
12343
12344 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
12345         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
12346         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
12347         return (uint64_t)ret_conv;
12348 }
12349
12350 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
12351         if ((_res & 1) != 0) return;
12352         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(((uint64_t)_res) & ~1);
12353         FREE((void*)_res);
12354         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
12355 }
12356
12357 void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
12358         LDKCVec_OutPointZ _res_constr;
12359         _res_constr.datalen = *((uint32_t*)_res);
12360         if (_res_constr.datalen > 0)
12361                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
12362         else
12363                 _res_constr.data = NULL;
12364         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12365         for (size_t k = 0; k < _res_constr.datalen; k++) {
12366                 uint32_t _res_conv_10 = _res_vals[k];
12367                 LDKOutPoint _res_conv_10_conv;
12368                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12369                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12370                 _res_constr.data[k] = _res_conv_10_conv;
12371         }
12372         CVec_OutPointZ_free(_res_constr);
12373 }
12374
12375 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
12376         if ((this_ptr & 1) != 0) return;
12377         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
12378         FREE((void*)this_ptr);
12379         PaymentPurpose_free(this_ptr_conv);
12380 }
12381
12382 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
12383         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
12384         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
12385         *ret_copy = PaymentPurpose_clone(orig_conv);
12386         uint64_t ret_ref = (uint64_t)ret_copy;
12387         return ret_ref;
12388 }
12389
12390 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
12391         LDKThirtyTwoBytes payment_preimage_ref;
12392         CHECK(*((uint32_t*)payment_preimage) == 32);
12393         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
12394         LDKThirtyTwoBytes payment_secret_ref;
12395         CHECK(*((uint32_t*)payment_secret) == 32);
12396         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
12397         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
12398         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
12399         uint64_t ret_ref = (uint64_t)ret_copy;
12400         return ret_ref;
12401 }
12402
12403 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
12404         LDKThirtyTwoBytes a_ref;
12405         CHECK(*((uint32_t*)a) == 32);
12406         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
12407         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
12408         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
12409         uint64_t ret_ref = (uint64_t)ret_copy;
12410         return ret_ref;
12411 }
12412
12413 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
12414         if ((this_ptr & 1) != 0) return;
12415         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1);
12416         FREE((void*)this_ptr);
12417         ClosureReason_free(this_ptr_conv);
12418 }
12419
12420 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
12421         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
12422         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12423         *ret_copy = ClosureReason_clone(orig_conv);
12424         uint64_t ret_ref = (uint64_t)ret_copy;
12425         return ret_ref;
12426 }
12427
12428 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
12429         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
12430         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12431         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
12432         uint64_t ret_ref = (uint64_t)ret_copy;
12433         return ret_ref;
12434 }
12435
12436 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
12437         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12438         *ret_copy = ClosureReason_holder_force_closed();
12439         uint64_t ret_ref = (uint64_t)ret_copy;
12440         return ret_ref;
12441 }
12442
12443 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
12444         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12445         *ret_copy = ClosureReason_cooperative_closure();
12446         uint64_t ret_ref = (uint64_t)ret_copy;
12447         return ret_ref;
12448 }
12449
12450 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
12451         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12452         *ret_copy = ClosureReason_commitment_tx_confirmed();
12453         uint64_t ret_ref = (uint64_t)ret_copy;
12454         return ret_ref;
12455 }
12456
12457 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
12458         LDKStr err_conv = str_ref_to_owned_c(err);
12459         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12460         *ret_copy = ClosureReason_processing_error(err_conv);
12461         uint64_t ret_ref = (uint64_t)ret_copy;
12462         return ret_ref;
12463 }
12464
12465 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
12466         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12467         *ret_copy = ClosureReason_disconnected_peer();
12468         uint64_t ret_ref = (uint64_t)ret_copy;
12469         return ret_ref;
12470 }
12471
12472 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
12473         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12474         *ret_copy = ClosureReason_outdated_channel_manager();
12475         uint64_t ret_ref = (uint64_t)ret_copy;
12476         return ret_ref;
12477 }
12478
12479 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
12480         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
12481         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
12482         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12483         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12484         CVec_u8Z_free(ret_var);
12485         return ret_arr;
12486 }
12487
12488 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
12489         if ((this_ptr & 1) != 0) return;
12490         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
12491         FREE((void*)this_ptr);
12492         Event_free(this_ptr_conv);
12493 }
12494
12495 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
12496         LDKEvent* orig_conv = (LDKEvent*)orig;
12497         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12498         *ret_copy = Event_clone(orig_conv);
12499         uint64_t ret_ref = (uint64_t)ret_copy;
12500         return ret_ref;
12501 }
12502
12503 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) {
12504         LDKThirtyTwoBytes temporary_channel_id_ref;
12505         CHECK(*((uint32_t*)temporary_channel_id) == 32);
12506         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
12507         LDKCVec_u8Z output_script_ref;
12508         output_script_ref.datalen = *((uint32_t*)output_script);
12509         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
12510         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
12511         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12512         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
12513         uint64_t ret_ref = (uint64_t)ret_copy;
12514         return ret_ref;
12515 }
12516
12517 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
12518         LDKThirtyTwoBytes payment_hash_ref;
12519         CHECK(*((uint32_t*)payment_hash) == 32);
12520         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
12521         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
12522         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
12523         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12524         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
12525         uint64_t ret_ref = (uint64_t)ret_copy;
12526         return ret_ref;
12527 }
12528
12529 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage, int8_tArray payment_hash) {
12530         LDKThirtyTwoBytes payment_preimage_ref;
12531         CHECK(*((uint32_t*)payment_preimage) == 32);
12532         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
12533         LDKThirtyTwoBytes payment_hash_ref;
12534         CHECK(*((uint32_t*)payment_hash) == 32);
12535         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
12536         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12537         *ret_copy = Event_payment_sent(payment_preimage_ref, payment_hash_ref);
12538         uint64_t ret_ref = (uint64_t)ret_copy;
12539         return ret_ref;
12540 }
12541
12542 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, uint32_t short_channel_id) {
12543         LDKThirtyTwoBytes payment_hash_ref;
12544         CHECK(*((uint32_t*)payment_hash) == 32);
12545         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
12546         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1);
12547         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
12548         LDKCVec_RouteHopZ path_constr;
12549         path_constr.datalen = *((uint32_t*)path);
12550         if (path_constr.datalen > 0)
12551                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12552         else
12553                 path_constr.data = NULL;
12554         uint32_t* path_vals = (uint32_t*)(path + 4);
12555         for (size_t k = 0; k < path_constr.datalen; k++) {
12556                 uint32_t path_conv_10 = path_vals[k];
12557                 LDKRouteHop path_conv_10_conv;
12558                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12559                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12560                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12561                 path_constr.data[k] = path_conv_10_conv;
12562         }
12563         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1);
12564         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
12565         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12566         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv);
12567         uint64_t ret_ref = (uint64_t)ret_copy;
12568         return ret_ref;
12569 }
12570
12571 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
12572         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12573         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
12574         uint64_t ret_ref = (uint64_t)ret_copy;
12575         return ret_ref;
12576 }
12577
12578 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
12579         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
12580         outputs_constr.datalen = *((uint32_t*)outputs);
12581         if (outputs_constr.datalen > 0)
12582                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12583         else
12584                 outputs_constr.data = NULL;
12585         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
12586         for (size_t b = 0; b < outputs_constr.datalen; b++) {
12587                 uint32_t outputs_conv_27 = outputs_vals[b];
12588                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
12589                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
12590                 outputs_constr.data[b] = outputs_conv_27_conv;
12591         }
12592         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12593         *ret_copy = Event_spendable_outputs(outputs_constr);
12594         uint64_t ret_ref = (uint64_t)ret_copy;
12595         return ret_ref;
12596 }
12597
12598 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
12599         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
12600         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
12601         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12602         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
12603         uint64_t ret_ref = (uint64_t)ret_copy;
12604         return ret_ref;
12605 }
12606
12607 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint32_t reason) {
12608         LDKThirtyTwoBytes channel_id_ref;
12609         CHECK(*((uint32_t*)channel_id) == 32);
12610         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
12611         LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1);
12612         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
12613         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12614         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
12615         uint64_t ret_ref = (uint64_t)ret_copy;
12616         return ret_ref;
12617 }
12618
12619 uint32_t  __attribute__((visibility("default"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
12620         LDKThirtyTwoBytes channel_id_ref;
12621         CHECK(*((uint32_t*)channel_id) == 32);
12622         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
12623         LDKTransaction transaction_ref;
12624         transaction_ref.datalen = *((uint32_t*)transaction);
12625         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
12626         memcpy(transaction_ref.data, (uint8_t*)(transaction + 4), transaction_ref.datalen);
12627         transaction_ref.data_is_owned = true;
12628         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12629         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
12630         uint64_t ret_ref = (uint64_t)ret_copy;
12631         return ret_ref;
12632 }
12633
12634 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
12635         LDKEvent* obj_conv = (LDKEvent*)obj;
12636         LDKCVec_u8Z ret_var = Event_write(obj_conv);
12637         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12638         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12639         CVec_u8Z_free(ret_var);
12640         return ret_arr;
12641 }
12642
12643 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
12644         if ((this_ptr & 1) != 0) return;
12645         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
12646         FREE((void*)this_ptr);
12647         MessageSendEvent_free(this_ptr_conv);
12648 }
12649
12650 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
12651         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
12652         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12653         *ret_copy = MessageSendEvent_clone(orig_conv);
12654         uint64_t ret_ref = (uint64_t)ret_copy;
12655         return ret_ref;
12656 }
12657
12658 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
12659         LDKPublicKey node_id_ref;
12660         CHECK(*((uint32_t*)node_id) == 33);
12661         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12662         LDKAcceptChannel msg_conv;
12663         msg_conv.inner = (void*)(msg & (~1));
12664         msg_conv.is_owned = (msg & 1) || (msg == 0);
12665         msg_conv = AcceptChannel_clone(&msg_conv);
12666         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12667         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
12668         uint64_t ret_ref = (uint64_t)ret_copy;
12669         return ret_ref;
12670 }
12671
12672 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
12673         LDKPublicKey node_id_ref;
12674         CHECK(*((uint32_t*)node_id) == 33);
12675         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12676         LDKOpenChannel msg_conv;
12677         msg_conv.inner = (void*)(msg & (~1));
12678         msg_conv.is_owned = (msg & 1) || (msg == 0);
12679         msg_conv = OpenChannel_clone(&msg_conv);
12680         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12681         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
12682         uint64_t ret_ref = (uint64_t)ret_copy;
12683         return ret_ref;
12684 }
12685
12686 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
12687         LDKPublicKey node_id_ref;
12688         CHECK(*((uint32_t*)node_id) == 33);
12689         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12690         LDKFundingCreated msg_conv;
12691         msg_conv.inner = (void*)(msg & (~1));
12692         msg_conv.is_owned = (msg & 1) || (msg == 0);
12693         msg_conv = FundingCreated_clone(&msg_conv);
12694         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12695         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
12696         uint64_t ret_ref = (uint64_t)ret_copy;
12697         return ret_ref;
12698 }
12699
12700 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
12701         LDKPublicKey node_id_ref;
12702         CHECK(*((uint32_t*)node_id) == 33);
12703         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12704         LDKFundingSigned msg_conv;
12705         msg_conv.inner = (void*)(msg & (~1));
12706         msg_conv.is_owned = (msg & 1) || (msg == 0);
12707         msg_conv = FundingSigned_clone(&msg_conv);
12708         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12709         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
12710         uint64_t ret_ref = (uint64_t)ret_copy;
12711         return ret_ref;
12712 }
12713
12714 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
12715         LDKPublicKey node_id_ref;
12716         CHECK(*((uint32_t*)node_id) == 33);
12717         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12718         LDKFundingLocked msg_conv;
12719         msg_conv.inner = (void*)(msg & (~1));
12720         msg_conv.is_owned = (msg & 1) || (msg == 0);
12721         msg_conv = FundingLocked_clone(&msg_conv);
12722         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12723         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
12724         uint64_t ret_ref = (uint64_t)ret_copy;
12725         return ret_ref;
12726 }
12727
12728 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
12729         LDKPublicKey node_id_ref;
12730         CHECK(*((uint32_t*)node_id) == 33);
12731         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12732         LDKAnnouncementSignatures msg_conv;
12733         msg_conv.inner = (void*)(msg & (~1));
12734         msg_conv.is_owned = (msg & 1) || (msg == 0);
12735         msg_conv = AnnouncementSignatures_clone(&msg_conv);
12736         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12737         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
12738         uint64_t ret_ref = (uint64_t)ret_copy;
12739         return ret_ref;
12740 }
12741
12742 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
12743         LDKPublicKey node_id_ref;
12744         CHECK(*((uint32_t*)node_id) == 33);
12745         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12746         LDKCommitmentUpdate updates_conv;
12747         updates_conv.inner = (void*)(updates & (~1));
12748         updates_conv.is_owned = (updates & 1) || (updates == 0);
12749         updates_conv = CommitmentUpdate_clone(&updates_conv);
12750         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12751         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
12752         uint64_t ret_ref = (uint64_t)ret_copy;
12753         return ret_ref;
12754 }
12755
12756 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
12757         LDKPublicKey node_id_ref;
12758         CHECK(*((uint32_t*)node_id) == 33);
12759         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12760         LDKRevokeAndACK msg_conv;
12761         msg_conv.inner = (void*)(msg & (~1));
12762         msg_conv.is_owned = (msg & 1) || (msg == 0);
12763         msg_conv = RevokeAndACK_clone(&msg_conv);
12764         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12765         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
12766         uint64_t ret_ref = (uint64_t)ret_copy;
12767         return ret_ref;
12768 }
12769
12770 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
12771         LDKPublicKey node_id_ref;
12772         CHECK(*((uint32_t*)node_id) == 33);
12773         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12774         LDKClosingSigned msg_conv;
12775         msg_conv.inner = (void*)(msg & (~1));
12776         msg_conv.is_owned = (msg & 1) || (msg == 0);
12777         msg_conv = ClosingSigned_clone(&msg_conv);
12778         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12779         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
12780         uint64_t ret_ref = (uint64_t)ret_copy;
12781         return ret_ref;
12782 }
12783
12784 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
12785         LDKPublicKey node_id_ref;
12786         CHECK(*((uint32_t*)node_id) == 33);
12787         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12788         LDKShutdown msg_conv;
12789         msg_conv.inner = (void*)(msg & (~1));
12790         msg_conv.is_owned = (msg & 1) || (msg == 0);
12791         msg_conv = Shutdown_clone(&msg_conv);
12792         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12793         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
12794         uint64_t ret_ref = (uint64_t)ret_copy;
12795         return ret_ref;
12796 }
12797
12798 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
12799         LDKPublicKey node_id_ref;
12800         CHECK(*((uint32_t*)node_id) == 33);
12801         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12802         LDKChannelReestablish msg_conv;
12803         msg_conv.inner = (void*)(msg & (~1));
12804         msg_conv.is_owned = (msg & 1) || (msg == 0);
12805         msg_conv = ChannelReestablish_clone(&msg_conv);
12806         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12807         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
12808         uint64_t ret_ref = (uint64_t)ret_copy;
12809         return ret_ref;
12810 }
12811
12812 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
12813         LDKChannelAnnouncement msg_conv;
12814         msg_conv.inner = (void*)(msg & (~1));
12815         msg_conv.is_owned = (msg & 1) || (msg == 0);
12816         msg_conv = ChannelAnnouncement_clone(&msg_conv);
12817         LDKChannelUpdate update_msg_conv;
12818         update_msg_conv.inner = (void*)(update_msg & (~1));
12819         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
12820         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
12821         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12822         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
12823         uint64_t ret_ref = (uint64_t)ret_copy;
12824         return ret_ref;
12825 }
12826
12827 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
12828         LDKNodeAnnouncement msg_conv;
12829         msg_conv.inner = (void*)(msg & (~1));
12830         msg_conv.is_owned = (msg & 1) || (msg == 0);
12831         msg_conv = NodeAnnouncement_clone(&msg_conv);
12832         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12833         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
12834         uint64_t ret_ref = (uint64_t)ret_copy;
12835         return ret_ref;
12836 }
12837
12838 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
12839         LDKChannelUpdate msg_conv;
12840         msg_conv.inner = (void*)(msg & (~1));
12841         msg_conv.is_owned = (msg & 1) || (msg == 0);
12842         msg_conv = ChannelUpdate_clone(&msg_conv);
12843         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12844         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
12845         uint64_t ret_ref = (uint64_t)ret_copy;
12846         return ret_ref;
12847 }
12848
12849 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
12850         LDKPublicKey node_id_ref;
12851         CHECK(*((uint32_t*)node_id) == 33);
12852         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12853         LDKChannelUpdate msg_conv;
12854         msg_conv.inner = (void*)(msg & (~1));
12855         msg_conv.is_owned = (msg & 1) || (msg == 0);
12856         msg_conv = ChannelUpdate_clone(&msg_conv);
12857         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12858         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
12859         uint64_t ret_ref = (uint64_t)ret_copy;
12860         return ret_ref;
12861 }
12862
12863 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
12864         LDKPublicKey node_id_ref;
12865         CHECK(*((uint32_t*)node_id) == 33);
12866         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12867         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
12868         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
12869         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12870         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
12871         uint64_t ret_ref = (uint64_t)ret_copy;
12872         return ret_ref;
12873 }
12874
12875 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
12876         LDKPublicKey node_id_ref;
12877         CHECK(*((uint32_t*)node_id) == 33);
12878         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12879         LDKQueryChannelRange msg_conv;
12880         msg_conv.inner = (void*)(msg & (~1));
12881         msg_conv.is_owned = (msg & 1) || (msg == 0);
12882         msg_conv = QueryChannelRange_clone(&msg_conv);
12883         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12884         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
12885         uint64_t ret_ref = (uint64_t)ret_copy;
12886         return ret_ref;
12887 }
12888
12889 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
12890         LDKPublicKey node_id_ref;
12891         CHECK(*((uint32_t*)node_id) == 33);
12892         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12893         LDKQueryShortChannelIds msg_conv;
12894         msg_conv.inner = (void*)(msg & (~1));
12895         msg_conv.is_owned = (msg & 1) || (msg == 0);
12896         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12897         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12898         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
12899         uint64_t ret_ref = (uint64_t)ret_copy;
12900         return ret_ref;
12901 }
12902
12903 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
12904         LDKPublicKey node_id_ref;
12905         CHECK(*((uint32_t*)node_id) == 33);
12906         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12907         LDKReplyChannelRange msg_conv;
12908         msg_conv.inner = (void*)(msg & (~1));
12909         msg_conv.is_owned = (msg & 1) || (msg == 0);
12910         msg_conv = ReplyChannelRange_clone(&msg_conv);
12911         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12912         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
12913         uint64_t ret_ref = (uint64_t)ret_copy;
12914         return ret_ref;
12915 }
12916
12917 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
12918         if ((this_ptr & 1) != 0) return;
12919         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12920         FREE((void*)this_ptr);
12921         MessageSendEventsProvider_free(this_ptr_conv);
12922 }
12923
12924 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
12925         if ((this_ptr & 1) != 0) return;
12926         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12927         FREE((void*)this_ptr);
12928         EventsProvider_free(this_ptr_conv);
12929 }
12930
12931 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
12932         if ((this_ptr & 1) != 0) return;
12933         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12934         FREE((void*)this_ptr);
12935         EventHandler_free(this_ptr_conv);
12936 }
12937
12938 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
12939         if ((this_ptr & 1) != 0) return;
12940         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12941         FREE((void*)this_ptr);
12942         APIError_free(this_ptr_conv);
12943 }
12944
12945 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
12946         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12947         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12948         *ret_copy = APIError_clone(orig_conv);
12949         uint64_t ret_ref = (uint64_t)ret_copy;
12950         return ret_ref;
12951 }
12952
12953 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
12954         LDKStr err_conv = str_ref_to_owned_c(err);
12955         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12956         *ret_copy = APIError_apimisuse_error(err_conv);
12957         uint64_t ret_ref = (uint64_t)ret_copy;
12958         return ret_ref;
12959 }
12960
12961 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
12962         LDKStr err_conv = str_ref_to_owned_c(err);
12963         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12964         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
12965         uint64_t ret_ref = (uint64_t)ret_copy;
12966         return ret_ref;
12967 }
12968
12969 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
12970         LDKStr err_conv = str_ref_to_owned_c(err);
12971         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12972         *ret_copy = APIError_route_error(err_conv);
12973         uint64_t ret_ref = (uint64_t)ret_copy;
12974         return ret_ref;
12975 }
12976
12977 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
12978         LDKStr err_conv = str_ref_to_owned_c(err);
12979         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12980         *ret_copy = APIError_channel_unavailable(err_conv);
12981         uint64_t ret_ref = (uint64_t)ret_copy;
12982         return ret_ref;
12983 }
12984
12985 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
12986         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12987         *ret_copy = APIError_monitor_update_failed();
12988         uint64_t ret_ref = (uint64_t)ret_copy;
12989         return ret_ref;
12990 }
12991
12992 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
12993         LDKShutdownScript script_conv;
12994         script_conv.inner = (void*)(script & (~1));
12995         script_conv.is_owned = (script & 1) || (script == 0);
12996         script_conv = ShutdownScript_clone(&script_conv);
12997         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12998         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
12999         uint64_t ret_ref = (uint64_t)ret_copy;
13000         return ret_ref;
13001 }
13002
13003 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
13004         LDKu8slice msg_ref;
13005         msg_ref.datalen = *((uint32_t*)msg);
13006         msg_ref.data = (int8_t*)(msg + 4);
13007         unsigned char sk_arr[32];
13008         CHECK(*((uint32_t*)sk) == 32);
13009         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
13010         unsigned char (*sk_ref)[32] = &sk_arr;
13011         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13012         *ret_conv = sign(msg_ref, sk_ref);
13013         return (uint64_t)ret_conv;
13014 }
13015
13016 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
13017         LDKu8slice msg_ref;
13018         msg_ref.datalen = *((uint32_t*)msg);
13019         msg_ref.data = (int8_t*)(msg + 4);
13020         LDKStr sig_conv = str_ref_to_owned_c(sig);
13021         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13022         *ret_conv = recover_pk(msg_ref, sig_conv);
13023         return (uint64_t)ret_conv;
13024 }
13025
13026 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
13027         LDKu8slice msg_ref;
13028         msg_ref.datalen = *((uint32_t*)msg);
13029         msg_ref.data = (int8_t*)(msg + 4);
13030         LDKStr sig_conv = str_ref_to_owned_c(sig);
13031         LDKPublicKey pk_ref;
13032         CHECK(*((uint32_t*)pk) == 33);
13033         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
13034         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13035         return ret_val;
13036 }
13037
13038 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
13039         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13040         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
13041         return ret_conv;
13042 }
13043
13044 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
13045         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
13046         return ret_conv;
13047 }
13048
13049 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
13050         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
13051         return ret_conv;
13052 }
13053
13054 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
13055         uint32_t ret_conv = LDKLevel_to_js(Level_info());
13056         return ret_conv;
13057 }
13058
13059 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
13060         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
13061         return ret_conv;
13062 }
13063
13064 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
13065         uint32_t ret_conv = LDKLevel_to_js(Level_error());
13066         return ret_conv;
13067 }
13068
13069 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
13070         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13071         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13072         jboolean ret_val = Level_eq(a_conv, b_conv);
13073         return ret_val;
13074 }
13075
13076 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
13077         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13078         int64_t ret_val = Level_hash(o_conv);
13079         return ret_val;
13080 }
13081
13082 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
13083         uint32_t ret_conv = LDKLevel_to_js(Level_max());
13084         return ret_conv;
13085 }
13086
13087 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
13088         if ((this_ptr & 1) != 0) return;
13089         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13090         FREE((void*)this_ptr);
13091         Logger_free(this_ptr_conv);
13092 }
13093
13094 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
13095         LDKChannelHandshakeConfig this_obj_conv;
13096         this_obj_conv.inner = (void*)(this_obj & (~1));
13097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13098         ChannelHandshakeConfig_free(this_obj_conv);
13099 }
13100
13101 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
13102         LDKChannelHandshakeConfig this_ptr_conv;
13103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13104         this_ptr_conv.is_owned = false;
13105         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13106         return ret_val;
13107 }
13108
13109 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
13110         LDKChannelHandshakeConfig this_ptr_conv;
13111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13112         this_ptr_conv.is_owned = false;
13113         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13114 }
13115
13116 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
13117         LDKChannelHandshakeConfig this_ptr_conv;
13118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13119         this_ptr_conv.is_owned = false;
13120         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13121         return ret_val;
13122 }
13123
13124 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
13125         LDKChannelHandshakeConfig this_ptr_conv;
13126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13127         this_ptr_conv.is_owned = false;
13128         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13129 }
13130
13131 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
13132         LDKChannelHandshakeConfig this_ptr_conv;
13133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13134         this_ptr_conv.is_owned = false;
13135         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13136         return ret_val;
13137 }
13138
13139 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
13140         LDKChannelHandshakeConfig this_ptr_conv;
13141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13142         this_ptr_conv.is_owned = false;
13143         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13144 }
13145
13146 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) {
13147         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
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_ChannelHandshakeConfig_clone(uint32_t orig) {
13158         LDKChannelHandshakeConfig orig_conv;
13159         orig_conv.inner = (void*)(orig & (~1));
13160         orig_conv.is_owned = false;
13161         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13164         uint64_t ret_ref = (uint64_t)ret_var.inner;
13165         if (ret_var.is_owned) {
13166                 ret_ref |= 1;
13167         }
13168         return ret_ref;
13169 }
13170
13171 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
13172         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13175         uint64_t ret_ref = (uint64_t)ret_var.inner;
13176         if (ret_var.is_owned) {
13177                 ret_ref |= 1;
13178         }
13179         return ret_ref;
13180 }
13181
13182 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
13183         LDKChannelHandshakeLimits this_obj_conv;
13184         this_obj_conv.inner = (void*)(this_obj & (~1));
13185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13186         ChannelHandshakeLimits_free(this_obj_conv);
13187 }
13188
13189 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
13190         LDKChannelHandshakeLimits this_ptr_conv;
13191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13192         this_ptr_conv.is_owned = false;
13193         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13194         return ret_val;
13195 }
13196
13197 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
13198         LDKChannelHandshakeLimits this_ptr_conv;
13199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13200         this_ptr_conv.is_owned = false;
13201         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13202 }
13203
13204 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
13205         LDKChannelHandshakeLimits this_ptr_conv;
13206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13207         this_ptr_conv.is_owned = false;
13208         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13209         return ret_val;
13210 }
13211
13212 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
13213         LDKChannelHandshakeLimits this_ptr_conv;
13214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13215         this_ptr_conv.is_owned = false;
13216         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13217 }
13218
13219 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
13220         LDKChannelHandshakeLimits this_ptr_conv;
13221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13222         this_ptr_conv.is_owned = false;
13223         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13224         return ret_val;
13225 }
13226
13227 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
13228         LDKChannelHandshakeLimits this_ptr_conv;
13229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13230         this_ptr_conv.is_owned = false;
13231         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13232 }
13233
13234 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
13235         LDKChannelHandshakeLimits this_ptr_conv;
13236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13237         this_ptr_conv.is_owned = false;
13238         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13239         return ret_val;
13240 }
13241
13242 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
13243         LDKChannelHandshakeLimits this_ptr_conv;
13244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13245         this_ptr_conv.is_owned = false;
13246         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13247 }
13248
13249 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
13250         LDKChannelHandshakeLimits this_ptr_conv;
13251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13252         this_ptr_conv.is_owned = false;
13253         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13254         return ret_val;
13255 }
13256
13257 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
13258         LDKChannelHandshakeLimits this_ptr_conv;
13259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13260         this_ptr_conv.is_owned = false;
13261         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13262 }
13263
13264 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
13265         LDKChannelHandshakeLimits this_ptr_conv;
13266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13267         this_ptr_conv.is_owned = false;
13268         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
13269         return ret_val;
13270 }
13271
13272 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
13273         LDKChannelHandshakeLimits this_ptr_conv;
13274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13275         this_ptr_conv.is_owned = false;
13276         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
13277 }
13278
13279 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
13280         LDKChannelHandshakeLimits this_ptr_conv;
13281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13282         this_ptr_conv.is_owned = false;
13283         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
13284         return ret_val;
13285 }
13286
13287 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
13288         LDKChannelHandshakeLimits this_ptr_conv;
13289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13290         this_ptr_conv.is_owned = false;
13291         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
13292 }
13293
13294 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
13295         LDKChannelHandshakeLimits this_ptr_conv;
13296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13297         this_ptr_conv.is_owned = false;
13298         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
13299         return ret_val;
13300 }
13301
13302 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
13303         LDKChannelHandshakeLimits this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
13307 }
13308
13309 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) {
13310         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);
13311         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13312         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13313         uint64_t ret_ref = (uint64_t)ret_var.inner;
13314         if (ret_var.is_owned) {
13315                 ret_ref |= 1;
13316         }
13317         return ret_ref;
13318 }
13319
13320 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
13321         LDKChannelHandshakeLimits orig_conv;
13322         orig_conv.inner = (void*)(orig & (~1));
13323         orig_conv.is_owned = false;
13324         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
13325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13327         uint64_t ret_ref = (uint64_t)ret_var.inner;
13328         if (ret_var.is_owned) {
13329                 ret_ref |= 1;
13330         }
13331         return ret_ref;
13332 }
13333
13334 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
13335         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
13336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13338         uint64_t ret_ref = (uint64_t)ret_var.inner;
13339         if (ret_var.is_owned) {
13340                 ret_ref |= 1;
13341         }
13342         return ret_ref;
13343 }
13344
13345 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
13346         LDKChannelConfig this_obj_conv;
13347         this_obj_conv.inner = (void*)(this_obj & (~1));
13348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13349         ChannelConfig_free(this_obj_conv);
13350 }
13351
13352 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
13353         LDKChannelConfig this_ptr_conv;
13354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13355         this_ptr_conv.is_owned = false;
13356         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
13357         return ret_val;
13358 }
13359
13360 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
13361         LDKChannelConfig this_ptr_conv;
13362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13363         this_ptr_conv.is_owned = false;
13364         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
13365 }
13366
13367 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
13368         LDKChannelConfig this_ptr_conv;
13369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13370         this_ptr_conv.is_owned = false;
13371         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
13372         return ret_val;
13373 }
13374
13375 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
13376         LDKChannelConfig this_ptr_conv;
13377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13378         this_ptr_conv.is_owned = false;
13379         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
13380 }
13381
13382 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
13383         LDKChannelConfig this_ptr_conv;
13384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13385         this_ptr_conv.is_owned = false;
13386         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
13387         return ret_val;
13388 }
13389
13390 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
13391         LDKChannelConfig this_ptr_conv;
13392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13393         this_ptr_conv.is_owned = false;
13394         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
13395 }
13396
13397 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
13398         LDKChannelConfig this_ptr_conv;
13399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13400         this_ptr_conv.is_owned = false;
13401         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
13402         return ret_val;
13403 }
13404
13405 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
13406         LDKChannelConfig this_ptr_conv;
13407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13408         this_ptr_conv.is_owned = false;
13409         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
13410 }
13411
13412 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
13413         LDKChannelConfig this_ptr_conv;
13414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13415         this_ptr_conv.is_owned = false;
13416         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
13417         return ret_val;
13418 }
13419
13420 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
13421         LDKChannelConfig this_ptr_conv;
13422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13423         this_ptr_conv.is_owned = false;
13424         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
13425 }
13426
13427 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
13428         LDKChannelConfig this_ptr_conv;
13429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13430         this_ptr_conv.is_owned = false;
13431         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
13432         return ret_val;
13433 }
13434
13435 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
13436         LDKChannelConfig this_ptr_conv;
13437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13438         this_ptr_conv.is_owned = false;
13439         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
13440 }
13441
13442 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
13443         LDKChannelConfig this_ptr_conv;
13444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13445         this_ptr_conv.is_owned = false;
13446         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
13447         return ret_val;
13448 }
13449
13450 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
13451         LDKChannelConfig this_ptr_conv;
13452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13453         this_ptr_conv.is_owned = false;
13454         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
13455 }
13456
13457 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) {
13458         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);
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_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
13469         LDKChannelConfig orig_conv;
13470         orig_conv.inner = (void*)(orig & (~1));
13471         orig_conv.is_owned = false;
13472         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
13473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13475         uint64_t ret_ref = (uint64_t)ret_var.inner;
13476         if (ret_var.is_owned) {
13477                 ret_ref |= 1;
13478         }
13479         return ret_ref;
13480 }
13481
13482 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
13483         LDKChannelConfig ret_var = ChannelConfig_default();
13484         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13485         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13486         uint64_t ret_ref = (uint64_t)ret_var.inner;
13487         if (ret_var.is_owned) {
13488                 ret_ref |= 1;
13489         }
13490         return ret_ref;
13491 }
13492
13493 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
13494         LDKChannelConfig obj_conv;
13495         obj_conv.inner = (void*)(obj & (~1));
13496         obj_conv.is_owned = false;
13497         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13498         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13499         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13500         CVec_u8Z_free(ret_var);
13501         return ret_arr;
13502 }
13503
13504 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
13505         LDKu8slice ser_ref;
13506         ser_ref.datalen = *((uint32_t*)ser);
13507         ser_ref.data = (int8_t*)(ser + 4);
13508         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13509         *ret_conv = ChannelConfig_read(ser_ref);
13510         return (uint64_t)ret_conv;
13511 }
13512
13513 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
13514         LDKUserConfig this_obj_conv;
13515         this_obj_conv.inner = (void*)(this_obj & (~1));
13516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13517         UserConfig_free(this_obj_conv);
13518 }
13519
13520 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
13521         LDKUserConfig this_ptr_conv;
13522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13523         this_ptr_conv.is_owned = false;
13524         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13527         uint64_t ret_ref = (uint64_t)ret_var.inner;
13528         if (ret_var.is_owned) {
13529                 ret_ref |= 1;
13530         }
13531         return ret_ref;
13532 }
13533
13534 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
13535         LDKUserConfig this_ptr_conv;
13536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13537         this_ptr_conv.is_owned = false;
13538         LDKChannelHandshakeConfig val_conv;
13539         val_conv.inner = (void*)(val & (~1));
13540         val_conv.is_owned = (val & 1) || (val == 0);
13541         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13542         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13543 }
13544
13545 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
13546         LDKUserConfig this_ptr_conv;
13547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13548         this_ptr_conv.is_owned = false;
13549         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13552         uint64_t ret_ref = (uint64_t)ret_var.inner;
13553         if (ret_var.is_owned) {
13554                 ret_ref |= 1;
13555         }
13556         return ret_ref;
13557 }
13558
13559 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
13560         LDKUserConfig this_ptr_conv;
13561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13562         this_ptr_conv.is_owned = false;
13563         LDKChannelHandshakeLimits val_conv;
13564         val_conv.inner = (void*)(val & (~1));
13565         val_conv.is_owned = (val & 1) || (val == 0);
13566         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13567         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13568 }
13569
13570 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
13571         LDKUserConfig this_ptr_conv;
13572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13573         this_ptr_conv.is_owned = false;
13574         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13577         uint64_t ret_ref = (uint64_t)ret_var.inner;
13578         if (ret_var.is_owned) {
13579                 ret_ref |= 1;
13580         }
13581         return ret_ref;
13582 }
13583
13584 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
13585         LDKUserConfig this_ptr_conv;
13586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13587         this_ptr_conv.is_owned = false;
13588         LDKChannelConfig val_conv;
13589         val_conv.inner = (void*)(val & (~1));
13590         val_conv.is_owned = (val & 1) || (val == 0);
13591         val_conv = ChannelConfig_clone(&val_conv);
13592         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13593 }
13594
13595 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
13596         LDKUserConfig this_ptr_conv;
13597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13598         this_ptr_conv.is_owned = false;
13599         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
13600         return ret_val;
13601 }
13602
13603 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
13604         LDKUserConfig this_ptr_conv;
13605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13606         this_ptr_conv.is_owned = false;
13607         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
13608 }
13609
13610 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) {
13611         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13612         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13613         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13614         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13615         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13616         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13617         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13618         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13619         LDKChannelConfig channel_options_arg_conv;
13620         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13621         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13622         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13623         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);
13624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13626         uint64_t ret_ref = (uint64_t)ret_var.inner;
13627         if (ret_var.is_owned) {
13628                 ret_ref |= 1;
13629         }
13630         return ret_ref;
13631 }
13632
13633 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
13634         LDKUserConfig orig_conv;
13635         orig_conv.inner = (void*)(orig & (~1));
13636         orig_conv.is_owned = false;
13637         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13640         uint64_t ret_ref = (uint64_t)ret_var.inner;
13641         if (ret_var.is_owned) {
13642                 ret_ref |= 1;
13643         }
13644         return ret_ref;
13645 }
13646
13647 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
13648         LDKUserConfig ret_var = UserConfig_default();
13649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13651         uint64_t ret_ref = (uint64_t)ret_var.inner;
13652         if (ret_var.is_owned) {
13653                 ret_ref |= 1;
13654         }
13655         return ret_ref;
13656 }
13657
13658 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
13659         LDKBestBlock this_obj_conv;
13660         this_obj_conv.inner = (void*)(this_obj & (~1));
13661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13662         BestBlock_free(this_obj_conv);
13663 }
13664
13665 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
13666         LDKBestBlock orig_conv;
13667         orig_conv.inner = (void*)(orig & (~1));
13668         orig_conv.is_owned = false;
13669         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
13670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13672         uint64_t ret_ref = (uint64_t)ret_var.inner;
13673         if (ret_var.is_owned) {
13674                 ret_ref |= 1;
13675         }
13676         return ret_ref;
13677 }
13678
13679 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
13680         LDKNetwork network_conv = LDKNetwork_from_js(network);
13681         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
13682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13684         uint64_t ret_ref = (uint64_t)ret_var.inner;
13685         if (ret_var.is_owned) {
13686                 ret_ref |= 1;
13687         }
13688         return ret_ref;
13689 }
13690
13691 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
13692         LDKThirtyTwoBytes block_hash_ref;
13693         CHECK(*((uint32_t*)block_hash) == 32);
13694         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
13695         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
13696         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13697         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13698         uint64_t ret_ref = (uint64_t)ret_var.inner;
13699         if (ret_var.is_owned) {
13700                 ret_ref |= 1;
13701         }
13702         return ret_ref;
13703 }
13704
13705 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
13706         LDKBestBlock this_arg_conv;
13707         this_arg_conv.inner = (void*)(this_arg & (~1));
13708         this_arg_conv.is_owned = false;
13709         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13710         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
13711         return ret_arr;
13712 }
13713
13714 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
13715         LDKBestBlock this_arg_conv;
13716         this_arg_conv.inner = (void*)(this_arg & (~1));
13717         this_arg_conv.is_owned = false;
13718         int32_t ret_val = BestBlock_height(&this_arg_conv);
13719         return ret_val;
13720 }
13721
13722 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
13723         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13724         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
13725         return ret_conv;
13726 }
13727
13728 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
13729         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
13730         return ret_conv;
13731 }
13732
13733 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
13734         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
13735         return ret_conv;
13736 }
13737
13738 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
13739         if ((this_ptr & 1) != 0) return;
13740         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13741         FREE((void*)this_ptr);
13742         Access_free(this_ptr_conv);
13743 }
13744
13745 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
13746         if ((this_ptr & 1) != 0) return;
13747         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13748         FREE((void*)this_ptr);
13749         Listen_free(this_ptr_conv);
13750 }
13751
13752 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
13753         if ((this_ptr & 1) != 0) return;
13754         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13755         FREE((void*)this_ptr);
13756         Confirm_free(this_ptr_conv);
13757 }
13758
13759 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
13760         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13761         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
13762         return ret_conv;
13763 }
13764
13765 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
13766         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
13767         return ret_conv;
13768 }
13769
13770 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
13771         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
13772         return ret_conv;
13773 }
13774
13775 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
13776         if ((this_ptr & 1) != 0) return;
13777         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13778         FREE((void*)this_ptr);
13779         Watch_free(this_ptr_conv);
13780 }
13781
13782 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
13783         if ((this_ptr & 1) != 0) return;
13784         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13785         FREE((void*)this_ptr);
13786         Filter_free(this_ptr_conv);
13787 }
13788
13789 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
13790         LDKWatchedOutput this_obj_conv;
13791         this_obj_conv.inner = (void*)(this_obj & (~1));
13792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13793         WatchedOutput_free(this_obj_conv);
13794 }
13795
13796 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
13797         LDKWatchedOutput this_ptr_conv;
13798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13799         this_ptr_conv.is_owned = false;
13800         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13801         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
13802         return ret_arr;
13803 }
13804
13805 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
13806         LDKWatchedOutput this_ptr_conv;
13807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13808         this_ptr_conv.is_owned = false;
13809         LDKThirtyTwoBytes val_ref;
13810         CHECK(*((uint32_t*)val) == 32);
13811         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13812         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13813 }
13814
13815 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
13816         LDKWatchedOutput this_ptr_conv;
13817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13818         this_ptr_conv.is_owned = false;
13819         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13820         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13821         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13822         uint64_t ret_ref = (uint64_t)ret_var.inner;
13823         if (ret_var.is_owned) {
13824                 ret_ref |= 1;
13825         }
13826         return ret_ref;
13827 }
13828
13829 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
13830         LDKWatchedOutput this_ptr_conv;
13831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13832         this_ptr_conv.is_owned = false;
13833         LDKOutPoint val_conv;
13834         val_conv.inner = (void*)(val & (~1));
13835         val_conv.is_owned = (val & 1) || (val == 0);
13836         val_conv = OutPoint_clone(&val_conv);
13837         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13838 }
13839
13840 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
13841         LDKWatchedOutput this_ptr_conv;
13842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13843         this_ptr_conv.is_owned = false;
13844         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13845         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13846         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13847         return ret_arr;
13848 }
13849
13850 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
13851         LDKWatchedOutput this_ptr_conv;
13852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13853         this_ptr_conv.is_owned = false;
13854         LDKCVec_u8Z val_ref;
13855         val_ref.datalen = *((uint32_t*)val);
13856         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13857         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
13858         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13859 }
13860
13861 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
13862         LDKThirtyTwoBytes block_hash_arg_ref;
13863         CHECK(*((uint32_t*)block_hash_arg) == 32);
13864         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
13865         LDKOutPoint outpoint_arg_conv;
13866         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13867         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13868         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13869         LDKCVec_u8Z script_pubkey_arg_ref;
13870         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
13871         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13872         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
13873         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13876         uint64_t ret_ref = (uint64_t)ret_var.inner;
13877         if (ret_var.is_owned) {
13878                 ret_ref |= 1;
13879         }
13880         return ret_ref;
13881 }
13882
13883 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
13884         LDKWatchedOutput orig_conv;
13885         orig_conv.inner = (void*)(orig & (~1));
13886         orig_conv.is_owned = false;
13887         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13888         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13889         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13890         uint64_t ret_ref = (uint64_t)ret_var.inner;
13891         if (ret_var.is_owned) {
13892                 ret_ref |= 1;
13893         }
13894         return ret_ref;
13895 }
13896
13897 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
13898         LDKWatchedOutput o_conv;
13899         o_conv.inner = (void*)(o & (~1));
13900         o_conv.is_owned = false;
13901         int64_t ret_val = WatchedOutput_hash(&o_conv);
13902         return ret_val;
13903 }
13904
13905 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
13906         if ((this_ptr & 1) != 0) return;
13907         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13908         FREE((void*)this_ptr);
13909         BroadcasterInterface_free(this_ptr_conv);
13910 }
13911
13912 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
13913         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13914         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
13915         return ret_conv;
13916 }
13917
13918 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
13919         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
13920         return ret_conv;
13921 }
13922
13923 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
13924         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
13925         return ret_conv;
13926 }
13927
13928 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
13929         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
13930         return ret_conv;
13931 }
13932
13933 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
13934         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
13935         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
13936         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
13937         return ret_val;
13938 }
13939
13940 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
13941         if ((this_ptr & 1) != 0) return;
13942         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13943         FREE((void*)this_ptr);
13944         FeeEstimator_free(this_ptr_conv);
13945 }
13946
13947 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
13948         if ((this_ptr & 1) != 0) return;
13949         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
13950         FREE((void*)this_ptr);
13951         Persist_free(this_ptr_conv);
13952 }
13953
13954 void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
13955         LDKLockedChannelMonitor this_obj_conv;
13956         this_obj_conv.inner = (void*)(this_obj & (~1));
13957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13958         LockedChannelMonitor_free(this_obj_conv);
13959 }
13960
13961 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
13962         LDKChainMonitor this_obj_conv;
13963         this_obj_conv.inner = (void*)(this_obj & (~1));
13964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13965         ChainMonitor_free(this_obj_conv);
13966 }
13967
13968 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
13969         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
13970         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
13971         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
13972                 // Manually implement clone for Java trait instances
13973         }
13974         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13975         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13976         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13977         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13978         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13981         uint64_t ret_ref = (uint64_t)ret_var.inner;
13982         if (ret_var.is_owned) {
13983                 ret_ref |= 1;
13984         }
13985         return ret_ref;
13986 }
13987
13988 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
13989         LDKChainMonitor this_arg_conv;
13990         this_arg_conv.inner = (void*)(this_arg & (~1));
13991         this_arg_conv.is_owned = false;
13992         LDKCVec_ChannelDetailsZ ignored_channels_constr;
13993         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
13994         if (ignored_channels_constr.datalen > 0)
13995                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13996         else
13997                 ignored_channels_constr.data = NULL;
13998         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
13999         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
14000                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
14001                 LDKChannelDetails ignored_channels_conv_16_conv;
14002                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
14003                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
14004                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
14005                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
14006         }
14007         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
14008         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14009         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14010         for (size_t j = 0; j < ret_var.datalen; j++) {
14011                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14012                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
14013                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
14014                 ret_arr_ptr[j] = ret_conv_9_ref;
14015         }
14016         FREE(ret_var.data);
14017         return ret_arr;
14018 }
14019
14020 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
14021         LDKChainMonitor this_arg_conv;
14022         this_arg_conv.inner = (void*)(this_arg & (~1));
14023         this_arg_conv.is_owned = false;
14024         LDKOutPoint funding_txo_conv;
14025         funding_txo_conv.inner = (void*)(funding_txo & (~1));
14026         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
14027         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
14028         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
14029         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
14030         return (uint64_t)ret_conv;
14031 }
14032
14033 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
14034         LDKChainMonitor this_arg_conv;
14035         this_arg_conv.inner = (void*)(this_arg & (~1));
14036         this_arg_conv.is_owned = false;
14037         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
14038         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14039         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14040         for (size_t k = 0; k < ret_var.datalen; k++) {
14041                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
14042                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14043                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14044                 uint64_t ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
14045                 if (ret_conv_10_var.is_owned) {
14046                         ret_conv_10_ref |= 1;
14047                 }
14048                 ret_arr_ptr[k] = ret_conv_10_ref;
14049         }
14050         FREE(ret_var.data);
14051         return ret_arr;
14052 }
14053
14054 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
14055         LDKChainMonitor this_arg_conv;
14056         this_arg_conv.inner = (void*)(this_arg & (~1));
14057         this_arg_conv.is_owned = false;
14058         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
14059         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
14060         return (uint64_t)ret_ret;
14061 }
14062
14063 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
14064         LDKChainMonitor this_arg_conv;
14065         this_arg_conv.inner = (void*)(this_arg & (~1));
14066         this_arg_conv.is_owned = false;
14067         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14068         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
14069         return (uint64_t)ret_ret;
14070 }
14071
14072 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
14073         LDKChainMonitor this_arg_conv;
14074         this_arg_conv.inner = (void*)(this_arg & (~1));
14075         this_arg_conv.is_owned = false;
14076         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
14077         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
14078         return (uint64_t)ret_ret;
14079 }
14080
14081 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
14082         LDKChainMonitor this_arg_conv;
14083         this_arg_conv.inner = (void*)(this_arg & (~1));
14084         this_arg_conv.is_owned = false;
14085         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14086         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14087         return (uint64_t)ret_ret;
14088 }
14089
14090 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
14091         LDKChannelMonitorUpdate this_obj_conv;
14092         this_obj_conv.inner = (void*)(this_obj & (~1));
14093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14094         ChannelMonitorUpdate_free(this_obj_conv);
14095 }
14096
14097 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
14098         LDKChannelMonitorUpdate this_ptr_conv;
14099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14100         this_ptr_conv.is_owned = false;
14101         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14102         return ret_val;
14103 }
14104
14105 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
14106         LDKChannelMonitorUpdate this_ptr_conv;
14107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14108         this_ptr_conv.is_owned = false;
14109         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14110 }
14111
14112 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
14113         LDKChannelMonitorUpdate orig_conv;
14114         orig_conv.inner = (void*)(orig & (~1));
14115         orig_conv.is_owned = false;
14116         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14119         uint64_t ret_ref = (uint64_t)ret_var.inner;
14120         if (ret_var.is_owned) {
14121                 ret_ref |= 1;
14122         }
14123         return ret_ref;
14124 }
14125
14126 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
14127         LDKChannelMonitorUpdate obj_conv;
14128         obj_conv.inner = (void*)(obj & (~1));
14129         obj_conv.is_owned = false;
14130         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14131         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14132         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14133         CVec_u8Z_free(ret_var);
14134         return ret_arr;
14135 }
14136
14137 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
14138         LDKu8slice ser_ref;
14139         ser_ref.datalen = *((uint32_t*)ser);
14140         ser_ref.data = (int8_t*)(ser + 4);
14141         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14142         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14143         return (uint64_t)ret_conv;
14144 }
14145
14146 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
14147         LDKMonitorUpdateError this_obj_conv;
14148         this_obj_conv.inner = (void*)(this_obj & (~1));
14149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14150         MonitorUpdateError_free(this_obj_conv);
14151 }
14152
14153 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
14154         LDKMonitorUpdateError orig_conv;
14155         orig_conv.inner = (void*)(orig & (~1));
14156         orig_conv.is_owned = false;
14157         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14158         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14159         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14160         uint64_t ret_ref = (uint64_t)ret_var.inner;
14161         if (ret_var.is_owned) {
14162                 ret_ref |= 1;
14163         }
14164         return ret_ref;
14165 }
14166
14167 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
14168         if ((this_ptr & 1) != 0) return;
14169         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14170         FREE((void*)this_ptr);
14171         MonitorEvent_free(this_ptr_conv);
14172 }
14173
14174 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
14175         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14176         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14177         *ret_copy = MonitorEvent_clone(orig_conv);
14178         uint64_t ret_ref = (uint64_t)ret_copy;
14179         return ret_ref;
14180 }
14181
14182 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
14183         LDKHTLCUpdate a_conv;
14184         a_conv.inner = (void*)(a & (~1));
14185         a_conv.is_owned = (a & 1) || (a == 0);
14186         a_conv = HTLCUpdate_clone(&a_conv);
14187         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14188         *ret_copy = MonitorEvent_htlcevent(a_conv);
14189         uint64_t ret_ref = (uint64_t)ret_copy;
14190         return ret_ref;
14191 }
14192
14193 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
14194         LDKOutPoint a_conv;
14195         a_conv.inner = (void*)(a & (~1));
14196         a_conv.is_owned = (a & 1) || (a == 0);
14197         a_conv = OutPoint_clone(&a_conv);
14198         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14199         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
14200         uint64_t ret_ref = (uint64_t)ret_copy;
14201         return ret_ref;
14202 }
14203
14204 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
14205         LDKHTLCUpdate this_obj_conv;
14206         this_obj_conv.inner = (void*)(this_obj & (~1));
14207         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14208         HTLCUpdate_free(this_obj_conv);
14209 }
14210
14211 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
14212         LDKHTLCUpdate orig_conv;
14213         orig_conv.inner = (void*)(orig & (~1));
14214         orig_conv.is_owned = false;
14215         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
14216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14218         uint64_t ret_ref = (uint64_t)ret_var.inner;
14219         if (ret_var.is_owned) {
14220                 ret_ref |= 1;
14221         }
14222         return ret_ref;
14223 }
14224
14225 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
14226         LDKHTLCUpdate obj_conv;
14227         obj_conv.inner = (void*)(obj & (~1));
14228         obj_conv.is_owned = false;
14229         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14230         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14231         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14232         CVec_u8Z_free(ret_var);
14233         return ret_arr;
14234 }
14235
14236 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
14237         LDKu8slice ser_ref;
14238         ser_ref.datalen = *((uint32_t*)ser);
14239         ser_ref.data = (int8_t*)(ser + 4);
14240         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14241         *ret_conv = HTLCUpdate_read(ser_ref);
14242         return (uint64_t)ret_conv;
14243 }
14244
14245 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
14246         if ((this_ptr & 1) != 0) return;
14247         LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1);
14248         FREE((void*)this_ptr);
14249         Balance_free(this_ptr_conv);
14250 }
14251
14252 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
14253         LDKBalance* orig_conv = (LDKBalance*)orig;
14254         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14255         *ret_copy = Balance_clone(orig_conv);
14256         uint64_t ret_ref = (uint64_t)ret_copy;
14257         return ret_ref;
14258 }
14259
14260 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
14261         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14262         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
14263         uint64_t ret_ref = (uint64_t)ret_copy;
14264         return ret_ref;
14265 }
14266
14267 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
14268         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14269         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
14270         uint64_t ret_ref = (uint64_t)ret_copy;
14271         return ret_ref;
14272 }
14273
14274 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
14275         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14276         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
14277         uint64_t ret_ref = (uint64_t)ret_copy;
14278         return ret_ref;
14279 }
14280
14281 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
14282         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14283         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
14284         uint64_t ret_ref = (uint64_t)ret_copy;
14285         return ret_ref;
14286 }
14287
14288 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
14289         LDKBalance* a_conv = (LDKBalance*)a;
14290         LDKBalance* b_conv = (LDKBalance*)b;
14291         jboolean ret_val = Balance_eq(a_conv, b_conv);
14292         return ret_val;
14293 }
14294
14295 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
14296         LDKChannelMonitor this_obj_conv;
14297         this_obj_conv.inner = (void*)(this_obj & (~1));
14298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14299         ChannelMonitor_free(this_obj_conv);
14300 }
14301
14302 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
14303         LDKChannelMonitor orig_conv;
14304         orig_conv.inner = (void*)(orig & (~1));
14305         orig_conv.is_owned = false;
14306         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14309         uint64_t ret_ref = (uint64_t)ret_var.inner;
14310         if (ret_var.is_owned) {
14311                 ret_ref |= 1;
14312         }
14313         return ret_ref;
14314 }
14315
14316 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
14317         LDKChannelMonitor obj_conv;
14318         obj_conv.inner = (void*)(obj & (~1));
14319         obj_conv.is_owned = false;
14320         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14321         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14322         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14323         CVec_u8Z_free(ret_var);
14324         return ret_arr;
14325 }
14326
14327 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) {
14328         LDKChannelMonitor this_arg_conv;
14329         this_arg_conv.inner = (void*)(this_arg & (~1));
14330         this_arg_conv.is_owned = false;
14331         LDKChannelMonitorUpdate updates_conv;
14332         updates_conv.inner = (void*)(updates & (~1));
14333         updates_conv.is_owned = false;
14334         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14335         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14336         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14337         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14338         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14339         return (uint64_t)ret_conv;
14340 }
14341
14342 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
14343         LDKChannelMonitor this_arg_conv;
14344         this_arg_conv.inner = (void*)(this_arg & (~1));
14345         this_arg_conv.is_owned = false;
14346         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14347         return ret_val;
14348 }
14349
14350 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
14351         LDKChannelMonitor this_arg_conv;
14352         this_arg_conv.inner = (void*)(this_arg & (~1));
14353         this_arg_conv.is_owned = false;
14354         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14355         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
14356         return ((uint64_t)ret_conv);
14357 }
14358
14359 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
14360         LDKChannelMonitor this_arg_conv;
14361         this_arg_conv.inner = (void*)(this_arg & (~1));
14362         this_arg_conv.is_owned = false;
14363         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14364         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14365         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14366         for (size_t o = 0; o < ret_var.datalen; o++) {
14367                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14368                 *ret_conv_40_conv = ret_var.data[o];
14369                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
14370         }
14371         FREE(ret_var.data);
14372         return ret_arr;
14373 }
14374
14375 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
14376         LDKChannelMonitor this_arg_conv;
14377         this_arg_conv.inner = (void*)(this_arg & (~1));
14378         this_arg_conv.is_owned = false;
14379         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14380         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14381 }
14382
14383 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
14384         LDKChannelMonitor this_arg_conv;
14385         this_arg_conv.inner = (void*)(this_arg & (~1));
14386         this_arg_conv.is_owned = false;
14387         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14388         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14389         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14390         for (size_t o = 0; o < ret_var.datalen; o++) {
14391                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14392                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14393                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14394                 ret_arr_ptr[o] = ret_conv_14_ref;
14395         }
14396         FREE(ret_var.data);
14397         return ret_arr;
14398 }
14399
14400 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
14401         LDKChannelMonitor this_arg_conv;
14402         this_arg_conv.inner = (void*)(this_arg & (~1));
14403         this_arg_conv.is_owned = false;
14404         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14405         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14406         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14407         for (size_t h = 0; h < ret_var.datalen; h++) {
14408                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
14409                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
14410                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
14411                 ret_arr_ptr[h] = ret_conv_7_ref;
14412         }
14413         FREE(ret_var.data);
14414         return ret_arr;
14415 }
14416
14417 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
14418         LDKChannelMonitor this_arg_conv;
14419         this_arg_conv.inner = (void*)(this_arg & (~1));
14420         this_arg_conv.is_owned = false;
14421         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14422         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
14423         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
14424         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
14425         for (size_t m = 0; m < ret_var.datalen; m++) {
14426                 LDKTransaction ret_conv_12_var = ret_var.data[m];
14427                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14428                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
14429                 Transaction_free(ret_conv_12_var);
14430                 ret_arr_ptr[m] = ret_conv_12_arr;
14431         }
14432         FREE(ret_var.data);
14433         return ret_arr;
14434 }
14435
14436 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) {
14437         LDKChannelMonitor this_arg_conv;
14438         this_arg_conv.inner = (void*)(this_arg & (~1));
14439         this_arg_conv.is_owned = false;
14440         unsigned char header_arr[80];
14441         CHECK(*((uint32_t*)header) == 80);
14442         memcpy(header_arr, (uint8_t*)(header + 4), 80);
14443         unsigned char (*header_ref)[80] = &header_arr;
14444         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14445         txdata_constr.datalen = *((uint32_t*)txdata);
14446         if (txdata_constr.datalen > 0)
14447                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14448         else
14449                 txdata_constr.data = NULL;
14450         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
14451         for (size_t c = 0; c < txdata_constr.datalen; c++) {
14452                 uint32_t txdata_conv_28 = txdata_vals[c];
14453                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
14454                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
14455                 txdata_constr.data[c] = txdata_conv_28_conv;
14456         }
14457         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14458         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14459         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14460         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);
14461         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14462         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14463         for (size_t n = 0; n < ret_var.datalen; n++) {
14464                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14465                 *ret_conv_39_conv = ret_var.data[n];
14466                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
14467         }
14468         FREE(ret_var.data);
14469         return ret_arr;
14470 }
14471
14472 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) {
14473         LDKChannelMonitor this_arg_conv;
14474         this_arg_conv.inner = (void*)(this_arg & (~1));
14475         this_arg_conv.is_owned = false;
14476         unsigned char header_arr[80];
14477         CHECK(*((uint32_t*)header) == 80);
14478         memcpy(header_arr, (uint8_t*)(header + 4), 80);
14479         unsigned char (*header_ref)[80] = &header_arr;
14480         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14481         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14482         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14483         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14484 }
14485
14486 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) {
14487         LDKChannelMonitor this_arg_conv;
14488         this_arg_conv.inner = (void*)(this_arg & (~1));
14489         this_arg_conv.is_owned = false;
14490         unsigned char header_arr[80];
14491         CHECK(*((uint32_t*)header) == 80);
14492         memcpy(header_arr, (uint8_t*)(header + 4), 80);
14493         unsigned char (*header_ref)[80] = &header_arr;
14494         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
14495         txdata_constr.datalen = *((uint32_t*)txdata);
14496         if (txdata_constr.datalen > 0)
14497                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14498         else
14499                 txdata_constr.data = NULL;
14500         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
14501         for (size_t c = 0; c < txdata_constr.datalen; c++) {
14502                 uint32_t txdata_conv_28 = txdata_vals[c];
14503                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
14504                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
14505                 txdata_constr.data[c] = txdata_conv_28_conv;
14506         }
14507         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14508         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14509         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14510         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);
14511         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14512         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14513         for (size_t n = 0; n < ret_var.datalen; n++) {
14514                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14515                 *ret_conv_39_conv = ret_var.data[n];
14516                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
14517         }
14518         FREE(ret_var.data);
14519         return ret_arr;
14520 }
14521
14522 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) {
14523         LDKChannelMonitor this_arg_conv;
14524         this_arg_conv.inner = (void*)(this_arg & (~1));
14525         this_arg_conv.is_owned = false;
14526         unsigned char txid_arr[32];
14527         CHECK(*((uint32_t*)txid) == 32);
14528         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
14529         unsigned char (*txid_ref)[32] = &txid_arr;
14530         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14531         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14532         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14533         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
14534 }
14535
14536 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) {
14537         LDKChannelMonitor this_arg_conv;
14538         this_arg_conv.inner = (void*)(this_arg & (~1));
14539         this_arg_conv.is_owned = false;
14540         unsigned char header_arr[80];
14541         CHECK(*((uint32_t*)header) == 80);
14542         memcpy(header_arr, (uint8_t*)(header + 4), 80);
14543         unsigned char (*header_ref)[80] = &header_arr;
14544         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14545         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14546         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14547         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14548         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14549         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14550         for (size_t n = 0; n < ret_var.datalen; n++) {
14551                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14552                 *ret_conv_39_conv = ret_var.data[n];
14553                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
14554         }
14555         FREE(ret_var.data);
14556         return ret_arr;
14557 }
14558
14559 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
14560         LDKChannelMonitor this_arg_conv;
14561         this_arg_conv.inner = (void*)(this_arg & (~1));
14562         this_arg_conv.is_owned = false;
14563         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14564         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
14565         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
14566         for (size_t m = 0; m < ret_var.datalen; m++) {
14567                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14568                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
14569                 ret_arr_ptr[m] = ret_conv_12_arr;
14570         }
14571         FREE(ret_var.data);
14572         return ret_arr;
14573 }
14574
14575 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
14576         LDKChannelMonitor this_arg_conv;
14577         this_arg_conv.inner = (void*)(this_arg & (~1));
14578         this_arg_conv.is_owned = false;
14579         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14582         uint64_t ret_ref = (uint64_t)ret_var.inner;
14583         if (ret_var.is_owned) {
14584                 ret_ref |= 1;
14585         }
14586         return ret_ref;
14587 }
14588
14589 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
14590         LDKChannelMonitor this_arg_conv;
14591         this_arg_conv.inner = (void*)(this_arg & (~1));
14592         this_arg_conv.is_owned = false;
14593         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
14594         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14595         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14596         for (size_t j = 0; j < ret_var.datalen; j++) {
14597                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14598                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
14599                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
14600                 ret_arr_ptr[j] = ret_conv_9_ref;
14601         }
14602         FREE(ret_var.data);
14603         return ret_arr;
14604 }
14605
14606 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
14607         LDKu8slice ser_ref;
14608         ser_ref.datalen = *((uint32_t*)ser);
14609         ser_ref.data = (int8_t*)(ser + 4);
14610         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14611         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14612         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14613         return (uint64_t)ret_conv;
14614 }
14615
14616 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
14617         LDKOutPoint this_obj_conv;
14618         this_obj_conv.inner = (void*)(this_obj & (~1));
14619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14620         OutPoint_free(this_obj_conv);
14621 }
14622
14623 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
14624         LDKOutPoint this_ptr_conv;
14625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14626         this_ptr_conv.is_owned = false;
14627         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14628         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
14629         return ret_arr;
14630 }
14631
14632 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
14633         LDKOutPoint this_ptr_conv;
14634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14635         this_ptr_conv.is_owned = false;
14636         LDKThirtyTwoBytes val_ref;
14637         CHECK(*((uint32_t*)val) == 32);
14638         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14639         OutPoint_set_txid(&this_ptr_conv, val_ref);
14640 }
14641
14642 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
14643         LDKOutPoint this_ptr_conv;
14644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14645         this_ptr_conv.is_owned = false;
14646         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14647         return ret_val;
14648 }
14649
14650 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
14651         LDKOutPoint this_ptr_conv;
14652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14653         this_ptr_conv.is_owned = false;
14654         OutPoint_set_index(&this_ptr_conv, val);
14655 }
14656
14657 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
14658         LDKThirtyTwoBytes txid_arg_ref;
14659         CHECK(*((uint32_t*)txid_arg) == 32);
14660         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
14661         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14664         uint64_t ret_ref = (uint64_t)ret_var.inner;
14665         if (ret_var.is_owned) {
14666                 ret_ref |= 1;
14667         }
14668         return ret_ref;
14669 }
14670
14671 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
14672         LDKOutPoint orig_conv;
14673         orig_conv.inner = (void*)(orig & (~1));
14674         orig_conv.is_owned = false;
14675         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14678         uint64_t ret_ref = (uint64_t)ret_var.inner;
14679         if (ret_var.is_owned) {
14680                 ret_ref |= 1;
14681         }
14682         return ret_ref;
14683 }
14684
14685 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
14686         LDKOutPoint a_conv;
14687         a_conv.inner = (void*)(a & (~1));
14688         a_conv.is_owned = false;
14689         LDKOutPoint b_conv;
14690         b_conv.inner = (void*)(b & (~1));
14691         b_conv.is_owned = false;
14692         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14693         return ret_val;
14694 }
14695
14696 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
14697         LDKOutPoint o_conv;
14698         o_conv.inner = (void*)(o & (~1));
14699         o_conv.is_owned = false;
14700         int64_t ret_val = OutPoint_hash(&o_conv);
14701         return ret_val;
14702 }
14703
14704 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
14705         LDKOutPoint this_arg_conv;
14706         this_arg_conv.inner = (void*)(this_arg & (~1));
14707         this_arg_conv.is_owned = false;
14708         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14709         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
14710         return ret_arr;
14711 }
14712
14713 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
14714         LDKOutPoint obj_conv;
14715         obj_conv.inner = (void*)(obj & (~1));
14716         obj_conv.is_owned = false;
14717         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14718         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14719         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14720         CVec_u8Z_free(ret_var);
14721         return ret_arr;
14722 }
14723
14724 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
14725         LDKu8slice ser_ref;
14726         ser_ref.datalen = *((uint32_t*)ser);
14727         ser_ref.data = (int8_t*)(ser + 4);
14728         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14729         *ret_conv = OutPoint_read(ser_ref);
14730         return (uint64_t)ret_conv;
14731 }
14732
14733 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
14734         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14735         this_obj_conv.inner = (void*)(this_obj & (~1));
14736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14737         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14738 }
14739
14740 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14741         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14743         this_ptr_conv.is_owned = false;
14744         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14745         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14746         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14747         uint64_t ret_ref = (uint64_t)ret_var.inner;
14748         if (ret_var.is_owned) {
14749                 ret_ref |= 1;
14750         }
14751         return ret_ref;
14752 }
14753
14754 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14755         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14757         this_ptr_conv.is_owned = false;
14758         LDKOutPoint val_conv;
14759         val_conv.inner = (void*)(val & (~1));
14760         val_conv.is_owned = (val & 1) || (val == 0);
14761         val_conv = OutPoint_clone(&val_conv);
14762         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14763 }
14764
14765 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
14766         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14768         this_ptr_conv.is_owned = false;
14769         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14770         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14771         return ret_arr;
14772 }
14773
14774 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14775         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14777         this_ptr_conv.is_owned = false;
14778         LDKPublicKey val_ref;
14779         CHECK(*((uint32_t*)val) == 33);
14780         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14781         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14782 }
14783
14784 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
14785         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14787         this_ptr_conv.is_owned = false;
14788         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14789         return ret_val;
14790 }
14791
14792 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14793         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14795         this_ptr_conv.is_owned = false;
14796         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14797 }
14798
14799 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14800         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14802         this_ptr_conv.is_owned = false;
14803         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14804         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14805         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14806 }
14807
14808 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
14809         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14811         this_ptr_conv.is_owned = false;
14812         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14813         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
14814         return ret_arr;
14815 }
14816
14817 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
14818         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14820         this_ptr_conv.is_owned = false;
14821         LDKPublicKey val_ref;
14822         CHECK(*((uint32_t*)val) == 33);
14823         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14824         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14825 }
14826
14827 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14828         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14830         this_ptr_conv.is_owned = false;
14831         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14832         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14833         return ret_arr;
14834 }
14835
14836 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14837         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14839         this_ptr_conv.is_owned = false;
14840         LDKThirtyTwoBytes val_ref;
14841         CHECK(*((uint32_t*)val) == 32);
14842         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14843         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14844 }
14845
14846 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14847         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14849         this_ptr_conv.is_owned = false;
14850         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14851         return ret_val;
14852 }
14853
14854 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14855         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14857         this_ptr_conv.is_owned = false;
14858         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14859 }
14860
14861 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) {
14862         LDKOutPoint outpoint_arg_conv;
14863         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14864         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14865         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14866         LDKPublicKey per_commitment_point_arg_ref;
14867         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
14868         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
14869         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14870         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
14871         LDKPublicKey revocation_pubkey_arg_ref;
14872         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
14873         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
14874         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14875         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
14876         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
14877         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);
14878         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14879         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14880         uint64_t ret_ref = (uint64_t)ret_var.inner;
14881         if (ret_var.is_owned) {
14882                 ret_ref |= 1;
14883         }
14884         return ret_ref;
14885 }
14886
14887 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
14888         LDKDelayedPaymentOutputDescriptor orig_conv;
14889         orig_conv.inner = (void*)(orig & (~1));
14890         orig_conv.is_owned = false;
14891         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14892         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14893         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14894         uint64_t ret_ref = (uint64_t)ret_var.inner;
14895         if (ret_var.is_owned) {
14896                 ret_ref |= 1;
14897         }
14898         return ret_ref;
14899 }
14900
14901 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
14902         LDKDelayedPaymentOutputDescriptor obj_conv;
14903         obj_conv.inner = (void*)(obj & (~1));
14904         obj_conv.is_owned = false;
14905         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14906         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14907         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14908         CVec_u8Z_free(ret_var);
14909         return ret_arr;
14910 }
14911
14912 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
14913         LDKu8slice ser_ref;
14914         ser_ref.datalen = *((uint32_t*)ser);
14915         ser_ref.data = (int8_t*)(ser + 4);
14916         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14917         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14918         return (uint64_t)ret_conv;
14919 }
14920
14921 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
14922         LDKStaticPaymentOutputDescriptor this_obj_conv;
14923         this_obj_conv.inner = (void*)(this_obj & (~1));
14924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14925         StaticPaymentOutputDescriptor_free(this_obj_conv);
14926 }
14927
14928 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14929         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14931         this_ptr_conv.is_owned = false;
14932         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
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 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14943         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14945         this_ptr_conv.is_owned = false;
14946         LDKOutPoint val_conv;
14947         val_conv.inner = (void*)(val & (~1));
14948         val_conv.is_owned = (val & 1) || (val == 0);
14949         val_conv = OutPoint_clone(&val_conv);
14950         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14951 }
14952
14953 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14954         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14956         this_ptr_conv.is_owned = false;
14957         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14958         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14959         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14960 }
14961
14962 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14963         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14965         this_ptr_conv.is_owned = false;
14966         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14967         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14968         return ret_arr;
14969 }
14970
14971 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14972         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14974         this_ptr_conv.is_owned = false;
14975         LDKThirtyTwoBytes val_ref;
14976         CHECK(*((uint32_t*)val) == 32);
14977         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14978         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14979 }
14980
14981 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14982         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14984         this_ptr_conv.is_owned = false;
14985         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14986         return ret_val;
14987 }
14988
14989 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14990         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14992         this_ptr_conv.is_owned = false;
14993         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14994 }
14995
14996 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) {
14997         LDKOutPoint outpoint_arg_conv;
14998         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14999         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15000         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15001         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15002         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
15003         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15004         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
15005         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
15006         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15009         uint64_t ret_ref = (uint64_t)ret_var.inner;
15010         if (ret_var.is_owned) {
15011                 ret_ref |= 1;
15012         }
15013         return ret_ref;
15014 }
15015
15016 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
15017         LDKStaticPaymentOutputDescriptor orig_conv;
15018         orig_conv.inner = (void*)(orig & (~1));
15019         orig_conv.is_owned = false;
15020         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15023         uint64_t ret_ref = (uint64_t)ret_var.inner;
15024         if (ret_var.is_owned) {
15025                 ret_ref |= 1;
15026         }
15027         return ret_ref;
15028 }
15029
15030 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
15031         LDKStaticPaymentOutputDescriptor obj_conv;
15032         obj_conv.inner = (void*)(obj & (~1));
15033         obj_conv.is_owned = false;
15034         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15035         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15036         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15037         CVec_u8Z_free(ret_var);
15038         return ret_arr;
15039 }
15040
15041 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
15042         LDKu8slice ser_ref;
15043         ser_ref.datalen = *((uint32_t*)ser);
15044         ser_ref.data = (int8_t*)(ser + 4);
15045         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15046         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15047         return (uint64_t)ret_conv;
15048 }
15049
15050 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
15051         if ((this_ptr & 1) != 0) return;
15052         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15053         FREE((void*)this_ptr);
15054         SpendableOutputDescriptor_free(this_ptr_conv);
15055 }
15056
15057 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
15058         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15059         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15060         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15061         uint64_t ret_ref = (uint64_t)ret_copy;
15062         return ret_ref;
15063 }
15064
15065 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
15066         LDKOutPoint outpoint_conv;
15067         outpoint_conv.inner = (void*)(outpoint & (~1));
15068         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
15069         outpoint_conv = OutPoint_clone(&outpoint_conv);
15070         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
15071         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
15072         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15073         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
15074         uint64_t ret_ref = (uint64_t)ret_copy;
15075         return ret_ref;
15076 }
15077
15078 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
15079         LDKDelayedPaymentOutputDescriptor a_conv;
15080         a_conv.inner = (void*)(a & (~1));
15081         a_conv.is_owned = (a & 1) || (a == 0);
15082         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
15083         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15084         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
15085         uint64_t ret_ref = (uint64_t)ret_copy;
15086         return ret_ref;
15087 }
15088
15089 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
15090         LDKStaticPaymentOutputDescriptor a_conv;
15091         a_conv.inner = (void*)(a & (~1));
15092         a_conv.is_owned = (a & 1) || (a == 0);
15093         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
15094         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15095         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
15096         uint64_t ret_ref = (uint64_t)ret_copy;
15097         return ret_ref;
15098 }
15099
15100 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
15101         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15102         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15103         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15104         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15105         CVec_u8Z_free(ret_var);
15106         return ret_arr;
15107 }
15108
15109 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
15110         LDKu8slice ser_ref;
15111         ser_ref.datalen = *((uint32_t*)ser);
15112         ser_ref.data = (int8_t*)(ser + 4);
15113         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15114         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15115         return (uint64_t)ret_conv;
15116 }
15117
15118 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
15119         if ((this_ptr & 1) != 0) return;
15120         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15121         FREE((void*)this_ptr);
15122         BaseSign_free(this_ptr_conv);
15123 }
15124
15125 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
15126         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15127         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
15128         *ret_ret = Sign_clone(orig_conv);
15129         return (uint64_t)ret_ret;
15130 }
15131
15132 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
15133         if ((this_ptr & 1) != 0) return;
15134         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15135         FREE((void*)this_ptr);
15136         Sign_free(this_ptr_conv);
15137 }
15138
15139 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
15140         if ((this_ptr & 1) != 0) return;
15141         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15142         FREE((void*)this_ptr);
15143         KeysInterface_free(this_ptr_conv);
15144 }
15145
15146 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
15147         LDKInMemorySigner this_obj_conv;
15148         this_obj_conv.inner = (void*)(this_obj & (~1));
15149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15150         InMemorySigner_free(this_obj_conv);
15151 }
15152
15153 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
15154         LDKInMemorySigner this_ptr_conv;
15155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15156         this_ptr_conv.is_owned = false;
15157         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15158         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
15159         return ret_arr;
15160 }
15161
15162 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
15163         LDKInMemorySigner this_ptr_conv;
15164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15165         this_ptr_conv.is_owned = false;
15166         LDKSecretKey val_ref;
15167         CHECK(*((uint32_t*)val) == 32);
15168         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
15169         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15170 }
15171
15172 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
15173         LDKInMemorySigner this_ptr_conv;
15174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15175         this_ptr_conv.is_owned = false;
15176         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15177         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
15178         return ret_arr;
15179 }
15180
15181 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
15182         LDKInMemorySigner this_ptr_conv;
15183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15184         this_ptr_conv.is_owned = false;
15185         LDKSecretKey val_ref;
15186         CHECK(*((uint32_t*)val) == 32);
15187         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
15188         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15189 }
15190
15191 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
15192         LDKInMemorySigner this_ptr_conv;
15193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15194         this_ptr_conv.is_owned = false;
15195         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15196         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
15197         return ret_arr;
15198 }
15199
15200 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
15201         LDKInMemorySigner this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         LDKSecretKey val_ref;
15205         CHECK(*((uint32_t*)val) == 32);
15206         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
15207         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15208 }
15209
15210 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
15211         LDKInMemorySigner this_ptr_conv;
15212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15213         this_ptr_conv.is_owned = false;
15214         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15215         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
15216         return ret_arr;
15217 }
15218
15219 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
15220         LDKInMemorySigner this_ptr_conv;
15221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15222         this_ptr_conv.is_owned = false;
15223         LDKSecretKey val_ref;
15224         CHECK(*((uint32_t*)val) == 32);
15225         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
15226         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15227 }
15228
15229 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
15230         LDKInMemorySigner this_ptr_conv;
15231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15232         this_ptr_conv.is_owned = false;
15233         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15234         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
15235         return ret_arr;
15236 }
15237
15238 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
15239         LDKInMemorySigner this_ptr_conv;
15240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15241         this_ptr_conv.is_owned = false;
15242         LDKSecretKey val_ref;
15243         CHECK(*((uint32_t*)val) == 32);
15244         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
15245         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15246 }
15247
15248 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
15249         LDKInMemorySigner this_ptr_conv;
15250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15251         this_ptr_conv.is_owned = false;
15252         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15253         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
15254         return ret_arr;
15255 }
15256
15257 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
15258         LDKInMemorySigner this_ptr_conv;
15259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15260         this_ptr_conv.is_owned = false;
15261         LDKThirtyTwoBytes val_ref;
15262         CHECK(*((uint32_t*)val) == 32);
15263         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15264         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15265 }
15266
15267 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
15268         LDKInMemorySigner orig_conv;
15269         orig_conv.inner = (void*)(orig & (~1));
15270         orig_conv.is_owned = false;
15271         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15274         uint64_t ret_ref = (uint64_t)ret_var.inner;
15275         if (ret_var.is_owned) {
15276                 ret_ref |= 1;
15277         }
15278         return ret_ref;
15279 }
15280
15281 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) {
15282         LDKSecretKey funding_key_ref;
15283         CHECK(*((uint32_t*)funding_key) == 32);
15284         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
15285         LDKSecretKey revocation_base_key_ref;
15286         CHECK(*((uint32_t*)revocation_base_key) == 32);
15287         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
15288         LDKSecretKey payment_key_ref;
15289         CHECK(*((uint32_t*)payment_key) == 32);
15290         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
15291         LDKSecretKey delayed_payment_base_key_ref;
15292         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
15293         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
15294         LDKSecretKey htlc_base_key_ref;
15295         CHECK(*((uint32_t*)htlc_base_key) == 32);
15296         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
15297         LDKThirtyTwoBytes commitment_seed_ref;
15298         CHECK(*((uint32_t*)commitment_seed) == 32);
15299         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
15300         LDKThirtyTwoBytes channel_keys_id_ref;
15301         CHECK(*((uint32_t*)channel_keys_id) == 32);
15302         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
15303         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);
15304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15306         uint64_t ret_ref = (uint64_t)ret_var.inner;
15307         if (ret_var.is_owned) {
15308                 ret_ref |= 1;
15309         }
15310         return ret_ref;
15311 }
15312
15313 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
15314         LDKInMemorySigner this_arg_conv;
15315         this_arg_conv.inner = (void*)(this_arg & (~1));
15316         this_arg_conv.is_owned = false;
15317         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15320         uint64_t ret_ref = (uint64_t)ret_var.inner;
15321         if (ret_var.is_owned) {
15322                 ret_ref |= 1;
15323         }
15324         return ret_ref;
15325 }
15326
15327 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
15328         LDKInMemorySigner this_arg_conv;
15329         this_arg_conv.inner = (void*)(this_arg & (~1));
15330         this_arg_conv.is_owned = false;
15331         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15332         return ret_val;
15333 }
15334
15335 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
15336         LDKInMemorySigner this_arg_conv;
15337         this_arg_conv.inner = (void*)(this_arg & (~1));
15338         this_arg_conv.is_owned = false;
15339         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15340         return ret_val;
15341 }
15342
15343 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
15344         LDKInMemorySigner this_arg_conv;
15345         this_arg_conv.inner = (void*)(this_arg & (~1));
15346         this_arg_conv.is_owned = false;
15347         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15348         return ret_val;
15349 }
15350
15351 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
15352         LDKInMemorySigner this_arg_conv;
15353         this_arg_conv.inner = (void*)(this_arg & (~1));
15354         this_arg_conv.is_owned = false;
15355         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
15356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15358         uint64_t ret_ref = (uint64_t)ret_var.inner;
15359         if (ret_var.is_owned) {
15360                 ret_ref |= 1;
15361         }
15362         return ret_ref;
15363 }
15364
15365 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
15366         LDKInMemorySigner this_arg_conv;
15367         this_arg_conv.inner = (void*)(this_arg & (~1));
15368         this_arg_conv.is_owned = false;
15369         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
15370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15372         uint64_t ret_ref = (uint64_t)ret_var.inner;
15373         if (ret_var.is_owned) {
15374                 ret_ref |= 1;
15375         }
15376         return ret_ref;
15377 }
15378
15379 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) {
15380         LDKInMemorySigner this_arg_conv;
15381         this_arg_conv.inner = (void*)(this_arg & (~1));
15382         this_arg_conv.is_owned = false;
15383         LDKTransaction spend_tx_ref;
15384         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
15385         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15386         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
15387         spend_tx_ref.data_is_owned = true;
15388         LDKStaticPaymentOutputDescriptor descriptor_conv;
15389         descriptor_conv.inner = (void*)(descriptor & (~1));
15390         descriptor_conv.is_owned = false;
15391         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15392         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15393         return (uint64_t)ret_conv;
15394 }
15395
15396 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) {
15397         LDKInMemorySigner this_arg_conv;
15398         this_arg_conv.inner = (void*)(this_arg & (~1));
15399         this_arg_conv.is_owned = false;
15400         LDKTransaction spend_tx_ref;
15401         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
15402         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
15403         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
15404         spend_tx_ref.data_is_owned = true;
15405         LDKDelayedPaymentOutputDescriptor descriptor_conv;
15406         descriptor_conv.inner = (void*)(descriptor & (~1));
15407         descriptor_conv.is_owned = false;
15408         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15409         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
15410         return (uint64_t)ret_conv;
15411 }
15412
15413 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
15414         LDKInMemorySigner this_arg_conv;
15415         this_arg_conv.inner = (void*)(this_arg & (~1));
15416         this_arg_conv.is_owned = false;
15417         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
15418         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
15419         return (uint64_t)ret_ret;
15420 }
15421
15422 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
15423         LDKInMemorySigner this_arg_conv;
15424         this_arg_conv.inner = (void*)(this_arg & (~1));
15425         this_arg_conv.is_owned = false;
15426         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
15427         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
15428         return (uint64_t)ret_ret;
15429 }
15430
15431 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
15432         LDKInMemorySigner obj_conv;
15433         obj_conv.inner = (void*)(obj & (~1));
15434         obj_conv.is_owned = false;
15435         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
15436         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15437         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15438         CVec_u8Z_free(ret_var);
15439         return ret_arr;
15440 }
15441
15442 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
15443         LDKu8slice ser_ref;
15444         ser_ref.datalen = *((uint32_t*)ser);
15445         ser_ref.data = (int8_t*)(ser + 4);
15446         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15447         *ret_conv = InMemorySigner_read(ser_ref);
15448         return (uint64_t)ret_conv;
15449 }
15450
15451 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
15452         LDKKeysManager this_obj_conv;
15453         this_obj_conv.inner = (void*)(this_obj & (~1));
15454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15455         KeysManager_free(this_obj_conv);
15456 }
15457
15458 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
15459         unsigned char seed_arr[32];
15460         CHECK(*((uint32_t*)seed) == 32);
15461         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
15462         unsigned char (*seed_ref)[32] = &seed_arr;
15463         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
15464         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15465         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15466         uint64_t ret_ref = (uint64_t)ret_var.inner;
15467         if (ret_var.is_owned) {
15468                 ret_ref |= 1;
15469         }
15470         return ret_ref;
15471 }
15472
15473 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
15474         LDKKeysManager this_arg_conv;
15475         this_arg_conv.inner = (void*)(this_arg & (~1));
15476         this_arg_conv.is_owned = false;
15477         unsigned char params_arr[32];
15478         CHECK(*((uint32_t*)params) == 32);
15479         memcpy(params_arr, (uint8_t*)(params + 4), 32);
15480         unsigned char (*params_ref)[32] = &params_arr;
15481         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
15482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15484         uint64_t ret_ref = (uint64_t)ret_var.inner;
15485         if (ret_var.is_owned) {
15486                 ret_ref |= 1;
15487         }
15488         return ret_ref;
15489 }
15490
15491 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) {
15492         LDKKeysManager this_arg_conv;
15493         this_arg_conv.inner = (void*)(this_arg & (~1));
15494         this_arg_conv.is_owned = false;
15495         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
15496         descriptors_constr.datalen = *((uint32_t*)descriptors);
15497         if (descriptors_constr.datalen > 0)
15498                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15499         else
15500                 descriptors_constr.data = NULL;
15501         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
15502         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
15503                 uint32_t descriptors_conv_27 = descriptors_vals[b];
15504                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
15505                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
15506                 descriptors_constr.data[b] = descriptors_conv_27_conv;
15507         }
15508         LDKCVec_TxOutZ outputs_constr;
15509         outputs_constr.datalen = *((uint32_t*)outputs);
15510         if (outputs_constr.datalen > 0)
15511                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15512         else
15513                 outputs_constr.data = NULL;
15514         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
15515         for (size_t h = 0; h < outputs_constr.datalen; h++) {
15516                 uint32_t outputs_conv_7 = outputs_vals[h];
15517                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
15518                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
15519                 outputs_constr.data[h] = outputs_conv_7_conv;
15520         }
15521         LDKCVec_u8Z change_destination_script_ref;
15522         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
15523         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
15524         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
15525         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15526         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
15527         return (uint64_t)ret_conv;
15528 }
15529
15530 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
15531         LDKKeysManager this_arg_conv;
15532         this_arg_conv.inner = (void*)(this_arg & (~1));
15533         this_arg_conv.is_owned = false;
15534         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15535         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
15536         return (uint64_t)ret_ret;
15537 }
15538
15539 void  __attribute__((visibility("default"))) TS_PaymentId_free(uint32_t this_obj) {
15540         LDKPaymentId this_obj_conv;
15541         this_obj_conv.inner = (void*)(this_obj & (~1));
15542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15543         PaymentId_free(this_obj_conv);
15544 }
15545
15546 int64_t  __attribute__((visibility("default"))) TS_PaymentId_hash(uint32_t o) {
15547         LDKPaymentId o_conv;
15548         o_conv.inner = (void*)(o & (~1));
15549         o_conv.is_owned = false;
15550         int64_t ret_val = PaymentId_hash(&o_conv);
15551         return ret_val;
15552 }
15553
15554 uint32_t  __attribute__((visibility("default"))) TS_PaymentId_clone(uint32_t orig) {
15555         LDKPaymentId orig_conv;
15556         orig_conv.inner = (void*)(orig & (~1));
15557         orig_conv.is_owned = false;
15558         LDKPaymentId ret_var = PaymentId_clone(&orig_conv);
15559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15561         uint64_t ret_ref = (uint64_t)ret_var.inner;
15562         if (ret_var.is_owned) {
15563                 ret_ref |= 1;
15564         }
15565         return ret_ref;
15566 }
15567
15568 jboolean  __attribute__((visibility("default"))) TS_PaymentId_eq(uint32_t a, uint32_t b) {
15569         LDKPaymentId a_conv;
15570         a_conv.inner = (void*)(a & (~1));
15571         a_conv.is_owned = false;
15572         LDKPaymentId b_conv;
15573         b_conv.inner = (void*)(b & (~1));
15574         b_conv.is_owned = false;
15575         jboolean ret_val = PaymentId_eq(&a_conv, &b_conv);
15576         return ret_val;
15577 }
15578
15579 int8_tArray  __attribute__((visibility("default"))) TS_PaymentId_write(uint32_t obj) {
15580         LDKPaymentId obj_conv;
15581         obj_conv.inner = (void*)(obj & (~1));
15582         obj_conv.is_owned = false;
15583         LDKCVec_u8Z ret_var = PaymentId_write(&obj_conv);
15584         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15585         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15586         CVec_u8Z_free(ret_var);
15587         return ret_arr;
15588 }
15589
15590 uint32_t  __attribute__((visibility("default"))) TS_PaymentId_read(int8_tArray ser) {
15591         LDKu8slice ser_ref;
15592         ser_ref.datalen = *((uint32_t*)ser);
15593         ser_ref.data = (int8_t*)(ser + 4);
15594         LDKCResult_PaymentIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdDecodeErrorZ), "LDKCResult_PaymentIdDecodeErrorZ");
15595         *ret_conv = PaymentId_read(ser_ref);
15596         return (uint64_t)ret_conv;
15597 }
15598
15599 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
15600         LDKChannelManager this_obj_conv;
15601         this_obj_conv.inner = (void*)(this_obj & (~1));
15602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15603         ChannelManager_free(this_obj_conv);
15604 }
15605
15606 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
15607         LDKChainParameters this_obj_conv;
15608         this_obj_conv.inner = (void*)(this_obj & (~1));
15609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15610         ChainParameters_free(this_obj_conv);
15611 }
15612
15613 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
15614         LDKChainParameters this_ptr_conv;
15615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15616         this_ptr_conv.is_owned = false;
15617         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
15618         return ret_conv;
15619 }
15620
15621 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
15622         LDKChainParameters this_ptr_conv;
15623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15624         this_ptr_conv.is_owned = false;
15625         LDKNetwork val_conv = LDKNetwork_from_js(val);
15626         ChainParameters_set_network(&this_ptr_conv, val_conv);
15627 }
15628
15629 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
15630         LDKChainParameters this_ptr_conv;
15631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15632         this_ptr_conv.is_owned = false;
15633         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15636         uint64_t ret_ref = (uint64_t)ret_var.inner;
15637         if (ret_var.is_owned) {
15638                 ret_ref |= 1;
15639         }
15640         return ret_ref;
15641 }
15642
15643 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
15644         LDKChainParameters this_ptr_conv;
15645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15646         this_ptr_conv.is_owned = false;
15647         LDKBestBlock val_conv;
15648         val_conv.inner = (void*)(val & (~1));
15649         val_conv.is_owned = (val & 1) || (val == 0);
15650         val_conv = BestBlock_clone(&val_conv);
15651         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15652 }
15653
15654 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
15655         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
15656         LDKBestBlock best_block_arg_conv;
15657         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15658         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15659         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15660         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15661         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15662         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15663         uint64_t ret_ref = (uint64_t)ret_var.inner;
15664         if (ret_var.is_owned) {
15665                 ret_ref |= 1;
15666         }
15667         return ret_ref;
15668 }
15669
15670 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
15671         LDKChainParameters orig_conv;
15672         orig_conv.inner = (void*)(orig & (~1));
15673         orig_conv.is_owned = false;
15674         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15677         uint64_t ret_ref = (uint64_t)ret_var.inner;
15678         if (ret_var.is_owned) {
15679                 ret_ref |= 1;
15680         }
15681         return ret_ref;
15682 }
15683
15684 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
15685         LDKCounterpartyForwardingInfo this_obj_conv;
15686         this_obj_conv.inner = (void*)(this_obj & (~1));
15687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15688         CounterpartyForwardingInfo_free(this_obj_conv);
15689 }
15690
15691 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
15692         LDKCounterpartyForwardingInfo this_ptr_conv;
15693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15694         this_ptr_conv.is_owned = false;
15695         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
15696         return ret_val;
15697 }
15698
15699 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
15700         LDKCounterpartyForwardingInfo this_ptr_conv;
15701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15702         this_ptr_conv.is_owned = false;
15703         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
15704 }
15705
15706 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
15707         LDKCounterpartyForwardingInfo this_ptr_conv;
15708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15709         this_ptr_conv.is_owned = false;
15710         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
15711         return ret_val;
15712 }
15713
15714 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
15715         LDKCounterpartyForwardingInfo this_ptr_conv;
15716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15717         this_ptr_conv.is_owned = false;
15718         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
15719 }
15720
15721 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
15722         LDKCounterpartyForwardingInfo this_ptr_conv;
15723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15724         this_ptr_conv.is_owned = false;
15725         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
15726         return ret_val;
15727 }
15728
15729 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
15730         LDKCounterpartyForwardingInfo this_ptr_conv;
15731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15732         this_ptr_conv.is_owned = false;
15733         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
15734 }
15735
15736 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) {
15737         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
15738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15740         uint64_t ret_ref = (uint64_t)ret_var.inner;
15741         if (ret_var.is_owned) {
15742                 ret_ref |= 1;
15743         }
15744         return ret_ref;
15745 }
15746
15747 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
15748         LDKCounterpartyForwardingInfo orig_conv;
15749         orig_conv.inner = (void*)(orig & (~1));
15750         orig_conv.is_owned = false;
15751         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
15752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15754         uint64_t ret_ref = (uint64_t)ret_var.inner;
15755         if (ret_var.is_owned) {
15756                 ret_ref |= 1;
15757         }
15758         return ret_ref;
15759 }
15760
15761 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
15762         LDKChannelCounterparty this_obj_conv;
15763         this_obj_conv.inner = (void*)(this_obj & (~1));
15764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15765         ChannelCounterparty_free(this_obj_conv);
15766 }
15767
15768 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
15769         LDKChannelCounterparty this_ptr_conv;
15770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15771         this_ptr_conv.is_owned = false;
15772         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15773         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
15774         return ret_arr;
15775 }
15776
15777 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
15778         LDKChannelCounterparty this_ptr_conv;
15779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15780         this_ptr_conv.is_owned = false;
15781         LDKPublicKey val_ref;
15782         CHECK(*((uint32_t*)val) == 33);
15783         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15784         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15785 }
15786
15787 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
15788         LDKChannelCounterparty this_ptr_conv;
15789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15790         this_ptr_conv.is_owned = false;
15791         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
15792         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15793         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15794         uint64_t ret_ref = (uint64_t)ret_var.inner;
15795         if (ret_var.is_owned) {
15796                 ret_ref |= 1;
15797         }
15798         return ret_ref;
15799 }
15800
15801 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
15802         LDKChannelCounterparty this_ptr_conv;
15803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15804         this_ptr_conv.is_owned = false;
15805         LDKInitFeatures val_conv;
15806         val_conv.inner = (void*)(val & (~1));
15807         val_conv.is_owned = (val & 1) || (val == 0);
15808         val_conv = InitFeatures_clone(&val_conv);
15809         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
15810 }
15811
15812 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15813         LDKChannelCounterparty this_ptr_conv;
15814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15815         this_ptr_conv.is_owned = false;
15816         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
15817         return ret_val;
15818 }
15819
15820 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
15821         LDKChannelCounterparty this_ptr_conv;
15822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15823         this_ptr_conv.is_owned = false;
15824         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
15825 }
15826
15827 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
15828         LDKChannelCounterparty this_ptr_conv;
15829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15830         this_ptr_conv.is_owned = false;
15831         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
15832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15834         uint64_t ret_ref = (uint64_t)ret_var.inner;
15835         if (ret_var.is_owned) {
15836                 ret_ref |= 1;
15837         }
15838         return ret_ref;
15839 }
15840
15841 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
15842         LDKChannelCounterparty this_ptr_conv;
15843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15844         this_ptr_conv.is_owned = false;
15845         LDKCounterpartyForwardingInfo val_conv;
15846         val_conv.inner = (void*)(val & (~1));
15847         val_conv.is_owned = (val & 1) || (val == 0);
15848         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
15849         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
15850 }
15851
15852 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) {
15853         LDKPublicKey node_id_arg_ref;
15854         CHECK(*((uint32_t*)node_id_arg) == 33);
15855         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
15856         LDKInitFeatures features_arg_conv;
15857         features_arg_conv.inner = (void*)(features_arg & (~1));
15858         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15859         features_arg_conv = InitFeatures_clone(&features_arg_conv);
15860         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
15861         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
15862         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
15863         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
15864         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
15865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15867         uint64_t ret_ref = (uint64_t)ret_var.inner;
15868         if (ret_var.is_owned) {
15869                 ret_ref |= 1;
15870         }
15871         return ret_ref;
15872 }
15873
15874 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
15875         LDKChannelCounterparty orig_conv;
15876         orig_conv.inner = (void*)(orig & (~1));
15877         orig_conv.is_owned = false;
15878         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
15879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15881         uint64_t ret_ref = (uint64_t)ret_var.inner;
15882         if (ret_var.is_owned) {
15883                 ret_ref |= 1;
15884         }
15885         return ret_ref;
15886 }
15887
15888 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
15889         LDKChannelDetails this_obj_conv;
15890         this_obj_conv.inner = (void*)(this_obj & (~1));
15891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15892         ChannelDetails_free(this_obj_conv);
15893 }
15894
15895 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
15896         LDKChannelDetails this_ptr_conv;
15897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15898         this_ptr_conv.is_owned = false;
15899         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15900         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
15901         return ret_arr;
15902 }
15903
15904 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15905         LDKChannelDetails this_ptr_conv;
15906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15907         this_ptr_conv.is_owned = false;
15908         LDKThirtyTwoBytes val_ref;
15909         CHECK(*((uint32_t*)val) == 32);
15910         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15911         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15912 }
15913
15914 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
15915         LDKChannelDetails this_ptr_conv;
15916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15917         this_ptr_conv.is_owned = false;
15918         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
15919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15921         uint64_t ret_ref = (uint64_t)ret_var.inner;
15922         if (ret_var.is_owned) {
15923                 ret_ref |= 1;
15924         }
15925         return ret_ref;
15926 }
15927
15928 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
15929         LDKChannelDetails this_ptr_conv;
15930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15931         this_ptr_conv.is_owned = false;
15932         LDKChannelCounterparty val_conv;
15933         val_conv.inner = (void*)(val & (~1));
15934         val_conv.is_owned = (val & 1) || (val == 0);
15935         val_conv = ChannelCounterparty_clone(&val_conv);
15936         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
15937 }
15938
15939 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
15940         LDKChannelDetails this_ptr_conv;
15941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15942         this_ptr_conv.is_owned = false;
15943         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15946         uint64_t ret_ref = (uint64_t)ret_var.inner;
15947         if (ret_var.is_owned) {
15948                 ret_ref |= 1;
15949         }
15950         return ret_ref;
15951 }
15952
15953 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
15954         LDKChannelDetails this_ptr_conv;
15955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15956         this_ptr_conv.is_owned = false;
15957         LDKOutPoint val_conv;
15958         val_conv.inner = (void*)(val & (~1));
15959         val_conv.is_owned = (val & 1) || (val == 0);
15960         val_conv = OutPoint_clone(&val_conv);
15961         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15962 }
15963
15964 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
15965         LDKChannelDetails this_ptr_conv;
15966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15967         this_ptr_conv.is_owned = false;
15968         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15969         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15970         uint64_t ret_ref = (uint64_t)ret_copy;
15971         return ret_ref;
15972 }
15973
15974 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
15975         LDKChannelDetails this_ptr_conv;
15976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15977         this_ptr_conv.is_owned = false;
15978         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15979         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
15980         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15981 }
15982
15983 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
15984         LDKChannelDetails this_ptr_conv;
15985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15986         this_ptr_conv.is_owned = false;
15987         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15988         return ret_val;
15989 }
15990
15991 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
15992         LDKChannelDetails this_ptr_conv;
15993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15994         this_ptr_conv.is_owned = false;
15995         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15996 }
15997
15998 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15999         LDKChannelDetails this_ptr_conv;
16000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16001         this_ptr_conv.is_owned = false;
16002         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16003         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16004         uint64_t ret_ref = (uint64_t)ret_copy;
16005         return ret_ref;
16006 }
16007
16008 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
16009         LDKChannelDetails this_ptr_conv;
16010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16011         this_ptr_conv.is_owned = false;
16012         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16013         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
16014         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16015 }
16016
16017 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
16018         LDKChannelDetails this_ptr_conv;
16019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16020         this_ptr_conv.is_owned = false;
16021         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
16022         return ret_val;
16023 }
16024
16025 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
16026         LDKChannelDetails this_ptr_conv;
16027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16028         this_ptr_conv.is_owned = false;
16029         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
16030 }
16031
16032 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
16033         LDKChannelDetails this_ptr_conv;
16034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16035         this_ptr_conv.is_owned = false;
16036         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16037         return ret_val;
16038 }
16039
16040 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
16041         LDKChannelDetails this_ptr_conv;
16042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16043         this_ptr_conv.is_owned = false;
16044         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16045 }
16046
16047 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
16048         LDKChannelDetails this_ptr_conv;
16049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16050         this_ptr_conv.is_owned = false;
16051         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16052         return ret_val;
16053 }
16054
16055 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
16056         LDKChannelDetails this_ptr_conv;
16057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16058         this_ptr_conv.is_owned = false;
16059         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16060 }
16061
16062 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
16063         LDKChannelDetails this_ptr_conv;
16064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16065         this_ptr_conv.is_owned = false;
16066         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16067         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16068         uint64_t ret_ref = (uint64_t)ret_copy;
16069         return ret_ref;
16070 }
16071
16072 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
16073         LDKChannelDetails this_ptr_conv;
16074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16075         this_ptr_conv.is_owned = false;
16076         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16077         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
16078         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16079 }
16080
16081 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
16082         LDKChannelDetails this_ptr_conv;
16083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16084         this_ptr_conv.is_owned = false;
16085         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16086         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16087         uint64_t ret_ref = (uint64_t)ret_copy;
16088         return ret_ref;
16089 }
16090
16091 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
16092         LDKChannelDetails this_ptr_conv;
16093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16094         this_ptr_conv.is_owned = false;
16095         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16096         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
16097         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16098 }
16099
16100 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
16101         LDKChannelDetails this_ptr_conv;
16102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16103         this_ptr_conv.is_owned = false;
16104         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16105         return ret_val;
16106 }
16107
16108 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
16109         LDKChannelDetails this_ptr_conv;
16110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16111         this_ptr_conv.is_owned = false;
16112         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16113 }
16114
16115 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
16116         LDKChannelDetails this_ptr_conv;
16117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16118         this_ptr_conv.is_owned = false;
16119         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16120         return ret_val;
16121 }
16122
16123 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
16124         LDKChannelDetails this_ptr_conv;
16125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16126         this_ptr_conv.is_owned = false;
16127         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16128 }
16129
16130 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
16131         LDKChannelDetails this_ptr_conv;
16132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16133         this_ptr_conv.is_owned = false;
16134         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16135         return ret_val;
16136 }
16137
16138 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
16139         LDKChannelDetails this_ptr_conv;
16140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16141         this_ptr_conv.is_owned = false;
16142         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16143 }
16144
16145 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
16146         LDKChannelDetails this_ptr_conv;
16147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16148         this_ptr_conv.is_owned = false;
16149         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16150         return ret_val;
16151 }
16152
16153 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
16154         LDKChannelDetails this_ptr_conv;
16155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16156         this_ptr_conv.is_owned = false;
16157         ChannelDetails_set_is_public(&this_ptr_conv, val);
16158 }
16159
16160 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
16161         LDKThirtyTwoBytes channel_id_arg_ref;
16162         CHECK(*((uint32_t*)channel_id_arg) == 32);
16163         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16164         LDKChannelCounterparty counterparty_arg_conv;
16165         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16166         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16167         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16168         LDKOutPoint funding_txo_arg_conv;
16169         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16170         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16171         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16172         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16173         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
16174         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16175         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16176         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
16177         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16178         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
16179         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
16180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16182         uint64_t ret_ref = (uint64_t)ret_var.inner;
16183         if (ret_var.is_owned) {
16184                 ret_ref |= 1;
16185         }
16186         return ret_ref;
16187 }
16188
16189 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
16190         LDKChannelDetails orig_conv;
16191         orig_conv.inner = (void*)(orig & (~1));
16192         orig_conv.is_owned = false;
16193         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16194         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16195         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16196         uint64_t ret_ref = (uint64_t)ret_var.inner;
16197         if (ret_var.is_owned) {
16198                 ret_ref |= 1;
16199         }
16200         return ret_ref;
16201 }
16202
16203 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
16204         if ((this_ptr & 1) != 0) return;
16205         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16206         FREE((void*)this_ptr);
16207         PaymentSendFailure_free(this_ptr_conv);
16208 }
16209
16210 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
16211         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16212         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16213         *ret_copy = PaymentSendFailure_clone(orig_conv);
16214         uint64_t ret_ref = (uint64_t)ret_copy;
16215         return ret_ref;
16216 }
16217
16218 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
16219         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
16220         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
16221         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16222         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
16223         uint64_t ret_ref = (uint64_t)ret_copy;
16224         return ret_ref;
16225 }
16226
16227 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
16228         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16229         a_constr.datalen = *((uint32_t*)a);
16230         if (a_constr.datalen > 0)
16231                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16232         else
16233                 a_constr.data = NULL;
16234         uint32_t* a_vals = (uint32_t*)(a + 4);
16235         for (size_t w = 0; w < a_constr.datalen; w++) {
16236                 uint32_t a_conv_22 = a_vals[w];
16237                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16238                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16239                 a_constr.data[w] = a_conv_22_conv;
16240         }
16241         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16242         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
16243         uint64_t ret_ref = (uint64_t)ret_copy;
16244         return ret_ref;
16245 }
16246
16247 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
16248         LDKCVec_APIErrorZ a_constr;
16249         a_constr.datalen = *((uint32_t*)a);
16250         if (a_constr.datalen > 0)
16251                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16252         else
16253                 a_constr.data = NULL;
16254         uint32_t* a_vals = (uint32_t*)(a + 4);
16255         for (size_t k = 0; k < a_constr.datalen; k++) {
16256                 uint32_t a_conv_10 = a_vals[k];
16257                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
16258                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
16259                 a_constr.data[k] = a_conv_10_conv;
16260         }
16261         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16262         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
16263         uint64_t ret_ref = (uint64_t)ret_copy;
16264         return ret_ref;
16265 }
16266
16267 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
16268         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16269         a_constr.datalen = *((uint32_t*)a);
16270         if (a_constr.datalen > 0)
16271                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16272         else
16273                 a_constr.data = NULL;
16274         uint32_t* a_vals = (uint32_t*)(a + 4);
16275         for (size_t w = 0; w < a_constr.datalen; w++) {
16276                 uint32_t a_conv_22 = a_vals[w];
16277                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16278                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16279                 a_constr.data[w] = a_conv_22_conv;
16280         }
16281         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16282         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
16283         uint64_t ret_ref = (uint64_t)ret_copy;
16284         return ret_ref;
16285 }
16286
16287 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) {
16288         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16289         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16290         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16291         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16292         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16293         LDKUserConfig config_conv;
16294         config_conv.inner = (void*)(config & (~1));
16295         config_conv.is_owned = (config & 1) || (config == 0);
16296         config_conv = UserConfig_clone(&config_conv);
16297         LDKChainParameters params_conv;
16298         params_conv.inner = (void*)(params & (~1));
16299         params_conv.is_owned = (params & 1) || (params == 0);
16300         params_conv = ChainParameters_clone(&params_conv);
16301         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16304         uint64_t ret_ref = (uint64_t)ret_var.inner;
16305         if (ret_var.is_owned) {
16306                 ret_ref |= 1;
16307         }
16308         return ret_ref;
16309 }
16310
16311 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
16312         LDKChannelManager this_arg_conv;
16313         this_arg_conv.inner = (void*)(this_arg & (~1));
16314         this_arg_conv.is_owned = false;
16315         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16316         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16317         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16318         uint64_t ret_ref = (uint64_t)ret_var.inner;
16319         if (ret_var.is_owned) {
16320                 ret_ref |= 1;
16321         }
16322         return ret_ref;
16323 }
16324
16325 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, uint32_t override_config) {
16326         LDKChannelManager this_arg_conv;
16327         this_arg_conv.inner = (void*)(this_arg & (~1));
16328         this_arg_conv.is_owned = false;
16329         LDKPublicKey their_network_key_ref;
16330         CHECK(*((uint32_t*)their_network_key) == 33);
16331         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
16332         LDKUserConfig override_config_conv;
16333         override_config_conv.inner = (void*)(override_config & (~1));
16334         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16335         override_config_conv = UserConfig_clone(&override_config_conv);
16336         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
16337         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
16338         return (uint64_t)ret_conv;
16339 }
16340
16341 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
16342         LDKChannelManager this_arg_conv;
16343         this_arg_conv.inner = (void*)(this_arg & (~1));
16344         this_arg_conv.is_owned = false;
16345         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16346         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16347         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16348         for (size_t q = 0; q < ret_var.datalen; q++) {
16349                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16350                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16351                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16352                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16353                 if (ret_conv_16_var.is_owned) {
16354                         ret_conv_16_ref |= 1;
16355                 }
16356                 ret_arr_ptr[q] = ret_conv_16_ref;
16357         }
16358         FREE(ret_var.data);
16359         return ret_arr;
16360 }
16361
16362 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
16363         LDKChannelManager this_arg_conv;
16364         this_arg_conv.inner = (void*)(this_arg & (~1));
16365         this_arg_conv.is_owned = false;
16366         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16367         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
16368         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
16369         for (size_t q = 0; q < ret_var.datalen; q++) {
16370                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16371                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16372                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16373                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16374                 if (ret_conv_16_var.is_owned) {
16375                         ret_conv_16_ref |= 1;
16376                 }
16377                 ret_arr_ptr[q] = ret_conv_16_ref;
16378         }
16379         FREE(ret_var.data);
16380         return ret_arr;
16381 }
16382
16383 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
16384         LDKChannelManager this_arg_conv;
16385         this_arg_conv.inner = (void*)(this_arg & (~1));
16386         this_arg_conv.is_owned = false;
16387         unsigned char channel_id_arr[32];
16388         CHECK(*((uint32_t*)channel_id) == 32);
16389         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
16390         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16391         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16392         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16393         return (uint64_t)ret_conv;
16394 }
16395
16396 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) {
16397         LDKChannelManager this_arg_conv;
16398         this_arg_conv.inner = (void*)(this_arg & (~1));
16399         this_arg_conv.is_owned = false;
16400         unsigned char channel_id_arr[32];
16401         CHECK(*((uint32_t*)channel_id) == 32);
16402         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
16403         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16404         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16405         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
16406         return (uint64_t)ret_conv;
16407 }
16408
16409 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
16410         LDKChannelManager this_arg_conv;
16411         this_arg_conv.inner = (void*)(this_arg & (~1));
16412         this_arg_conv.is_owned = false;
16413         unsigned char channel_id_arr[32];
16414         CHECK(*((uint32_t*)channel_id) == 32);
16415         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
16416         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16417         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16418         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16419         return (uint64_t)ret_conv;
16420 }
16421
16422 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
16423         LDKChannelManager this_arg_conv;
16424         this_arg_conv.inner = (void*)(this_arg & (~1));
16425         this_arg_conv.is_owned = false;
16426         ChannelManager_force_close_all_channels(&this_arg_conv);
16427 }
16428
16429 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
16430         LDKChannelManager this_arg_conv;
16431         this_arg_conv.inner = (void*)(this_arg & (~1));
16432         this_arg_conv.is_owned = false;
16433         LDKRoute route_conv;
16434         route_conv.inner = (void*)(route & (~1));
16435         route_conv.is_owned = false;
16436         LDKThirtyTwoBytes payment_hash_ref;
16437         CHECK(*((uint32_t*)payment_hash) == 32);
16438         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16439         LDKThirtyTwoBytes payment_secret_ref;
16440         CHECK(*((uint32_t*)payment_secret) == 32);
16441         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
16442         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
16443         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16444         return (uint64_t)ret_conv;
16445 }
16446
16447 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, uint32_t payment_id) {
16448         LDKChannelManager this_arg_conv;
16449         this_arg_conv.inner = (void*)(this_arg & (~1));
16450         this_arg_conv.is_owned = false;
16451         LDKRoute route_conv;
16452         route_conv.inner = (void*)(route & (~1));
16453         route_conv.is_owned = false;
16454         LDKPaymentId payment_id_conv;
16455         payment_id_conv.inner = (void*)(payment_id & (~1));
16456         payment_id_conv.is_owned = (payment_id & 1) || (payment_id == 0);
16457         payment_id_conv = PaymentId_clone(&payment_id_conv);
16458         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16459         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_conv);
16460         return (uint64_t)ret_conv;
16461 }
16462
16463 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
16464         LDKChannelManager this_arg_conv;
16465         this_arg_conv.inner = (void*)(this_arg & (~1));
16466         this_arg_conv.is_owned = false;
16467         LDKRoute route_conv;
16468         route_conv.inner = (void*)(route & (~1));
16469         route_conv.is_owned = false;
16470         LDKThirtyTwoBytes payment_preimage_ref;
16471         CHECK(*((uint32_t*)payment_preimage) == 32);
16472         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
16473         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16474         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
16475         return (uint64_t)ret_conv;
16476 }
16477
16478 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
16479         LDKChannelManager this_arg_conv;
16480         this_arg_conv.inner = (void*)(this_arg & (~1));
16481         this_arg_conv.is_owned = false;
16482         unsigned char temporary_channel_id_arr[32];
16483         CHECK(*((uint32_t*)temporary_channel_id) == 32);
16484         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
16485         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16486         LDKTransaction funding_transaction_ref;
16487         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
16488         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16489         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
16490         funding_transaction_ref.data_is_owned = true;
16491         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16492         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16493         return (uint64_t)ret_conv;
16494 }
16495
16496 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
16497         LDKChannelManager this_arg_conv;
16498         this_arg_conv.inner = (void*)(this_arg & (~1));
16499         this_arg_conv.is_owned = false;
16500         LDKThreeBytes rgb_ref;
16501         CHECK(*((uint32_t*)rgb) == 3);
16502         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
16503         LDKThirtyTwoBytes alias_ref;
16504         CHECK(*((uint32_t*)alias) == 32);
16505         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
16506         LDKCVec_NetAddressZ addresses_constr;
16507         addresses_constr.datalen = *((uint32_t*)addresses);
16508         if (addresses_constr.datalen > 0)
16509                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16510         else
16511                 addresses_constr.data = NULL;
16512         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
16513         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16514                 uint32_t addresses_conv_12 = addresses_vals[m];
16515                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16516                 addresses_constr.data[m] = addresses_conv_12_conv;
16517         }
16518         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16519 }
16520
16521 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
16522         LDKChannelManager this_arg_conv;
16523         this_arg_conv.inner = (void*)(this_arg & (~1));
16524         this_arg_conv.is_owned = false;
16525         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16526 }
16527
16528 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
16529         LDKChannelManager this_arg_conv;
16530         this_arg_conv.inner = (void*)(this_arg & (~1));
16531         this_arg_conv.is_owned = false;
16532         ChannelManager_timer_tick_occurred(&this_arg_conv);
16533 }
16534
16535 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
16536         LDKChannelManager this_arg_conv;
16537         this_arg_conv.inner = (void*)(this_arg & (~1));
16538         this_arg_conv.is_owned = false;
16539         unsigned char payment_hash_arr[32];
16540         CHECK(*((uint32_t*)payment_hash) == 32);
16541         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
16542         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16543         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16544         return ret_val;
16545 }
16546
16547 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
16548         LDKChannelManager this_arg_conv;
16549         this_arg_conv.inner = (void*)(this_arg & (~1));
16550         this_arg_conv.is_owned = false;
16551         LDKThirtyTwoBytes payment_preimage_ref;
16552         CHECK(*((uint32_t*)payment_preimage) == 32);
16553         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
16554         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16555         return ret_val;
16556 }
16557
16558 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
16559         LDKChannelManager this_arg_conv;
16560         this_arg_conv.inner = (void*)(this_arg & (~1));
16561         this_arg_conv.is_owned = false;
16562         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16563         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
16564         return ret_arr;
16565 }
16566
16567 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
16568         LDKChannelManager this_arg_conv;
16569         this_arg_conv.inner = (void*)(this_arg & (~1));
16570         this_arg_conv.is_owned = false;
16571         LDKOutPoint funding_txo_conv;
16572         funding_txo_conv.inner = (void*)(funding_txo & (~1));
16573         funding_txo_conv.is_owned = false;
16574         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
16575 }
16576
16577 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) {
16578         LDKChannelManager this_arg_conv;
16579         this_arg_conv.inner = (void*)(this_arg & (~1));
16580         this_arg_conv.is_owned = false;
16581         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16582         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
16583         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16584         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
16585         return ((uint64_t)ret_conv);
16586 }
16587
16588 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) {
16589         LDKChannelManager this_arg_conv;
16590         this_arg_conv.inner = (void*)(this_arg & (~1));
16591         this_arg_conv.is_owned = false;
16592         LDKThirtyTwoBytes payment_hash_ref;
16593         CHECK(*((uint32_t*)payment_hash) == 32);
16594         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16595         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
16596         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
16597         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16598         *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);
16599         return (uint64_t)ret_conv;
16600 }
16601
16602 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
16603         LDKChannelManager this_arg_conv;
16604         this_arg_conv.inner = (void*)(this_arg & (~1));
16605         this_arg_conv.is_owned = false;
16606         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16607         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16608         return (uint64_t)ret_ret;
16609 }
16610
16611 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
16612         LDKChannelManager this_arg_conv;
16613         this_arg_conv.inner = (void*)(this_arg & (~1));
16614         this_arg_conv.is_owned = false;
16615         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16616         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16617         return (uint64_t)ret_ret;
16618 }
16619
16620 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
16621         LDKChannelManager this_arg_conv;
16622         this_arg_conv.inner = (void*)(this_arg & (~1));
16623         this_arg_conv.is_owned = false;
16624         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
16625         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
16626         return (uint64_t)ret_ret;
16627 }
16628
16629 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
16630         LDKChannelManager this_arg_conv;
16631         this_arg_conv.inner = (void*)(this_arg & (~1));
16632         this_arg_conv.is_owned = false;
16633         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16634         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
16635         return (uint64_t)ret_ret;
16636 }
16637
16638 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
16639         LDKChannelManager this_arg_conv;
16640         this_arg_conv.inner = (void*)(this_arg & (~1));
16641         this_arg_conv.is_owned = false;
16642         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16643         return ret_val;
16644 }
16645
16646 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
16647         LDKChannelManager this_arg_conv;
16648         this_arg_conv.inner = (void*)(this_arg & (~1));
16649         this_arg_conv.is_owned = false;
16650         ChannelManager_await_persistable_update(&this_arg_conv);
16651 }
16652
16653 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
16654         LDKChannelManager this_arg_conv;
16655         this_arg_conv.inner = (void*)(this_arg & (~1));
16656         this_arg_conv.is_owned = false;
16657         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16660         uint64_t ret_ref = (uint64_t)ret_var.inner;
16661         if (ret_var.is_owned) {
16662                 ret_ref |= 1;
16663         }
16664         return ret_ref;
16665 }
16666
16667 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
16668         LDKChannelManager this_arg_conv;
16669         this_arg_conv.inner = (void*)(this_arg & (~1));
16670         this_arg_conv.is_owned = false;
16671         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16672         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16673         return (uint64_t)ret_ret;
16674 }
16675
16676 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
16677         LDKChannelManager obj_conv;
16678         obj_conv.inner = (void*)(obj & (~1));
16679         obj_conv.is_owned = false;
16680         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16681         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16682         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16683         CVec_u8Z_free(ret_var);
16684         return ret_arr;
16685 }
16686
16687 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
16688         LDKChannelManagerReadArgs this_obj_conv;
16689         this_obj_conv.inner = (void*)(this_obj & (~1));
16690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16691         ChannelManagerReadArgs_free(this_obj_conv);
16692 }
16693
16694 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
16695         LDKChannelManagerReadArgs this_ptr_conv;
16696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16697         this_ptr_conv.is_owned = false;
16698         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16699         return ret_ret;
16700 }
16701
16702 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
16703         LDKChannelManagerReadArgs this_ptr_conv;
16704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16705         this_ptr_conv.is_owned = false;
16706         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16707         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16708 }
16709
16710 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
16711         LDKChannelManagerReadArgs this_ptr_conv;
16712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16713         this_ptr_conv.is_owned = false;
16714         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16715         return ret_ret;
16716 }
16717
16718 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
16719         LDKChannelManagerReadArgs this_ptr_conv;
16720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16721         this_ptr_conv.is_owned = false;
16722         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16723         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16724 }
16725
16726 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
16727         LDKChannelManagerReadArgs this_ptr_conv;
16728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16729         this_ptr_conv.is_owned = false;
16730         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16731         return ret_ret;
16732 }
16733
16734 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
16735         LDKChannelManagerReadArgs this_ptr_conv;
16736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16737         this_ptr_conv.is_owned = false;
16738         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16739         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16740 }
16741
16742 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
16743         LDKChannelManagerReadArgs this_ptr_conv;
16744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16745         this_ptr_conv.is_owned = false;
16746         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16747         return ret_ret;
16748 }
16749
16750 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
16751         LDKChannelManagerReadArgs this_ptr_conv;
16752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16753         this_ptr_conv.is_owned = false;
16754         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16755         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16756 }
16757
16758 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
16759         LDKChannelManagerReadArgs this_ptr_conv;
16760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16761         this_ptr_conv.is_owned = false;
16762         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16763         return ret_ret;
16764 }
16765
16766 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
16767         LDKChannelManagerReadArgs this_ptr_conv;
16768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16769         this_ptr_conv.is_owned = false;
16770         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16771         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16772 }
16773
16774 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
16775         LDKChannelManagerReadArgs this_ptr_conv;
16776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16777         this_ptr_conv.is_owned = false;
16778         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16779         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16780         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16781         uint64_t ret_ref = (uint64_t)ret_var.inner;
16782         if (ret_var.is_owned) {
16783                 ret_ref |= 1;
16784         }
16785         return ret_ref;
16786 }
16787
16788 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
16789         LDKChannelManagerReadArgs this_ptr_conv;
16790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16791         this_ptr_conv.is_owned = false;
16792         LDKUserConfig val_conv;
16793         val_conv.inner = (void*)(val & (~1));
16794         val_conv.is_owned = (val & 1) || (val == 0);
16795         val_conv = UserConfig_clone(&val_conv);
16796         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16797 }
16798
16799 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) {
16800         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16801         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16802         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16803         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16804         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16805         LDKUserConfig default_config_conv;
16806         default_config_conv.inner = (void*)(default_config & (~1));
16807         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16808         default_config_conv = UserConfig_clone(&default_config_conv);
16809         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16810         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
16811         if (channel_monitors_constr.datalen > 0)
16812                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16813         else
16814                 channel_monitors_constr.data = NULL;
16815         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
16816         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16817                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
16818                 LDKChannelMonitor channel_monitors_conv_16_conv;
16819                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16820                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16821                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16822         }
16823         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);
16824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16826         uint64_t ret_ref = (uint64_t)ret_var.inner;
16827         if (ret_var.is_owned) {
16828                 ret_ref |= 1;
16829         }
16830         return ret_ref;
16831 }
16832
16833 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
16834         LDKu8slice ser_ref;
16835         ser_ref.datalen = *((uint32_t*)ser);
16836         ser_ref.data = (int8_t*)(ser + 4);
16837         LDKChannelManagerReadArgs arg_conv;
16838         arg_conv.inner = (void*)(arg & (~1));
16839         arg_conv.is_owned = (arg & 1) || (arg == 0);
16840         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16841         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16842         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16843         return (uint64_t)ret_conv;
16844 }
16845
16846 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
16847         LDKDecodeError this_obj_conv;
16848         this_obj_conv.inner = (void*)(this_obj & (~1));
16849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16850         DecodeError_free(this_obj_conv);
16851 }
16852
16853 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
16854         LDKDecodeError orig_conv;
16855         orig_conv.inner = (void*)(orig & (~1));
16856         orig_conv.is_owned = false;
16857         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16860         uint64_t ret_ref = (uint64_t)ret_var.inner;
16861         if (ret_var.is_owned) {
16862                 ret_ref |= 1;
16863         }
16864         return ret_ref;
16865 }
16866
16867 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
16868         LDKInit this_obj_conv;
16869         this_obj_conv.inner = (void*)(this_obj & (~1));
16870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16871         Init_free(this_obj_conv);
16872 }
16873
16874 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
16875         LDKInit this_ptr_conv;
16876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16877         this_ptr_conv.is_owned = false;
16878         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16881         uint64_t ret_ref = (uint64_t)ret_var.inner;
16882         if (ret_var.is_owned) {
16883                 ret_ref |= 1;
16884         }
16885         return ret_ref;
16886 }
16887
16888 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
16889         LDKInit this_ptr_conv;
16890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16891         this_ptr_conv.is_owned = false;
16892         LDKInitFeatures val_conv;
16893         val_conv.inner = (void*)(val & (~1));
16894         val_conv.is_owned = (val & 1) || (val == 0);
16895         val_conv = InitFeatures_clone(&val_conv);
16896         Init_set_features(&this_ptr_conv, val_conv);
16897 }
16898
16899 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
16900         LDKInitFeatures features_arg_conv;
16901         features_arg_conv.inner = (void*)(features_arg & (~1));
16902         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16903         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16904         LDKInit ret_var = Init_new(features_arg_conv);
16905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16907         uint64_t ret_ref = (uint64_t)ret_var.inner;
16908         if (ret_var.is_owned) {
16909                 ret_ref |= 1;
16910         }
16911         return ret_ref;
16912 }
16913
16914 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
16915         LDKInit orig_conv;
16916         orig_conv.inner = (void*)(orig & (~1));
16917         orig_conv.is_owned = false;
16918         LDKInit ret_var = Init_clone(&orig_conv);
16919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16921         uint64_t ret_ref = (uint64_t)ret_var.inner;
16922         if (ret_var.is_owned) {
16923                 ret_ref |= 1;
16924         }
16925         return ret_ref;
16926 }
16927
16928 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
16929         LDKErrorMessage this_obj_conv;
16930         this_obj_conv.inner = (void*)(this_obj & (~1));
16931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16932         ErrorMessage_free(this_obj_conv);
16933 }
16934
16935 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
16936         LDKErrorMessage this_ptr_conv;
16937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16938         this_ptr_conv.is_owned = false;
16939         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16940         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
16941         return ret_arr;
16942 }
16943
16944 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16945         LDKErrorMessage this_ptr_conv;
16946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16947         this_ptr_conv.is_owned = false;
16948         LDKThirtyTwoBytes val_ref;
16949         CHECK(*((uint32_t*)val) == 32);
16950         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16951         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16952 }
16953
16954 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
16955         LDKErrorMessage this_ptr_conv;
16956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16957         this_ptr_conv.is_owned = false;
16958         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16959         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16960         Str_free(ret_str);
16961         return ret_conv;
16962 }
16963
16964 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
16965         LDKErrorMessage this_ptr_conv;
16966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16967         this_ptr_conv.is_owned = false;
16968         LDKStr val_conv = str_ref_to_owned_c(val);
16969         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16970 }
16971
16972 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
16973         LDKThirtyTwoBytes channel_id_arg_ref;
16974         CHECK(*((uint32_t*)channel_id_arg) == 32);
16975         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16976         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
16977         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16978         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16979         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16980         uint64_t ret_ref = (uint64_t)ret_var.inner;
16981         if (ret_var.is_owned) {
16982                 ret_ref |= 1;
16983         }
16984         return ret_ref;
16985 }
16986
16987 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
16988         LDKErrorMessage orig_conv;
16989         orig_conv.inner = (void*)(orig & (~1));
16990         orig_conv.is_owned = false;
16991         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16994         uint64_t ret_ref = (uint64_t)ret_var.inner;
16995         if (ret_var.is_owned) {
16996                 ret_ref |= 1;
16997         }
16998         return ret_ref;
16999 }
17000
17001 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
17002         LDKPing this_obj_conv;
17003         this_obj_conv.inner = (void*)(this_obj & (~1));
17004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17005         Ping_free(this_obj_conv);
17006 }
17007
17008 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
17009         LDKPing this_ptr_conv;
17010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17011         this_ptr_conv.is_owned = false;
17012         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17013         return ret_val;
17014 }
17015
17016 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
17017         LDKPing this_ptr_conv;
17018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17019         this_ptr_conv.is_owned = false;
17020         Ping_set_ponglen(&this_ptr_conv, val);
17021 }
17022
17023 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
17024         LDKPing this_ptr_conv;
17025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17026         this_ptr_conv.is_owned = false;
17027         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17028         return ret_val;
17029 }
17030
17031 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
17032         LDKPing this_ptr_conv;
17033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17034         this_ptr_conv.is_owned = false;
17035         Ping_set_byteslen(&this_ptr_conv, val);
17036 }
17037
17038 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
17039         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17040         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17041         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17042         uint64_t ret_ref = (uint64_t)ret_var.inner;
17043         if (ret_var.is_owned) {
17044                 ret_ref |= 1;
17045         }
17046         return ret_ref;
17047 }
17048
17049 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
17050         LDKPing orig_conv;
17051         orig_conv.inner = (void*)(orig & (~1));
17052         orig_conv.is_owned = false;
17053         LDKPing ret_var = Ping_clone(&orig_conv);
17054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17056         uint64_t ret_ref = (uint64_t)ret_var.inner;
17057         if (ret_var.is_owned) {
17058                 ret_ref |= 1;
17059         }
17060         return ret_ref;
17061 }
17062
17063 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
17064         LDKPong this_obj_conv;
17065         this_obj_conv.inner = (void*)(this_obj & (~1));
17066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17067         Pong_free(this_obj_conv);
17068 }
17069
17070 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
17071         LDKPong this_ptr_conv;
17072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17073         this_ptr_conv.is_owned = false;
17074         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17075         return ret_val;
17076 }
17077
17078 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
17079         LDKPong this_ptr_conv;
17080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17081         this_ptr_conv.is_owned = false;
17082         Pong_set_byteslen(&this_ptr_conv, val);
17083 }
17084
17085 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
17086         LDKPong ret_var = Pong_new(byteslen_arg);
17087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17089         uint64_t ret_ref = (uint64_t)ret_var.inner;
17090         if (ret_var.is_owned) {
17091                 ret_ref |= 1;
17092         }
17093         return ret_ref;
17094 }
17095
17096 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
17097         LDKPong orig_conv;
17098         orig_conv.inner = (void*)(orig & (~1));
17099         orig_conv.is_owned = false;
17100         LDKPong ret_var = Pong_clone(&orig_conv);
17101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17103         uint64_t ret_ref = (uint64_t)ret_var.inner;
17104         if (ret_var.is_owned) {
17105                 ret_ref |= 1;
17106         }
17107         return ret_ref;
17108 }
17109
17110 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
17111         LDKOpenChannel this_obj_conv;
17112         this_obj_conv.inner = (void*)(this_obj & (~1));
17113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17114         OpenChannel_free(this_obj_conv);
17115 }
17116
17117 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
17118         LDKOpenChannel this_ptr_conv;
17119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17120         this_ptr_conv.is_owned = false;
17121         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17122         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
17123         return ret_arr;
17124 }
17125
17126 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
17127         LDKOpenChannel this_ptr_conv;
17128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17129         this_ptr_conv.is_owned = false;
17130         LDKThirtyTwoBytes val_ref;
17131         CHECK(*((uint32_t*)val) == 32);
17132         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17133         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17134 }
17135
17136 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
17137         LDKOpenChannel this_ptr_conv;
17138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17139         this_ptr_conv.is_owned = false;
17140         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17141         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
17142         return ret_arr;
17143 }
17144
17145 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
17146         LDKOpenChannel this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         LDKThirtyTwoBytes val_ref;
17150         CHECK(*((uint32_t*)val) == 32);
17151         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17152         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17153 }
17154
17155 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
17156         LDKOpenChannel this_ptr_conv;
17157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17158         this_ptr_conv.is_owned = false;
17159         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17160         return ret_val;
17161 }
17162
17163 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
17164         LDKOpenChannel this_ptr_conv;
17165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17166         this_ptr_conv.is_owned = false;
17167         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17168 }
17169
17170 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
17171         LDKOpenChannel this_ptr_conv;
17172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17173         this_ptr_conv.is_owned = false;
17174         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17175         return ret_val;
17176 }
17177
17178 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
17179         LDKOpenChannel this_ptr_conv;
17180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17181         this_ptr_conv.is_owned = false;
17182         OpenChannel_set_push_msat(&this_ptr_conv, val);
17183 }
17184
17185 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
17186         LDKOpenChannel this_ptr_conv;
17187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17188         this_ptr_conv.is_owned = false;
17189         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17190         return ret_val;
17191 }
17192
17193 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
17194         LDKOpenChannel this_ptr_conv;
17195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17196         this_ptr_conv.is_owned = false;
17197         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17198 }
17199
17200 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
17201         LDKOpenChannel this_ptr_conv;
17202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17203         this_ptr_conv.is_owned = false;
17204         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17205         return ret_val;
17206 }
17207
17208 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
17209         LDKOpenChannel this_ptr_conv;
17210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17211         this_ptr_conv.is_owned = false;
17212         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17213 }
17214
17215 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
17216         LDKOpenChannel this_ptr_conv;
17217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17218         this_ptr_conv.is_owned = false;
17219         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17220         return ret_val;
17221 }
17222
17223 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
17224         LDKOpenChannel this_ptr_conv;
17225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17226         this_ptr_conv.is_owned = false;
17227         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17228 }
17229
17230 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
17231         LDKOpenChannel this_ptr_conv;
17232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17233         this_ptr_conv.is_owned = false;
17234         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17235         return ret_val;
17236 }
17237
17238 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17239         LDKOpenChannel this_ptr_conv;
17240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17241         this_ptr_conv.is_owned = false;
17242         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17243 }
17244
17245 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
17246         LDKOpenChannel this_ptr_conv;
17247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17248         this_ptr_conv.is_owned = false;
17249         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17250         return ret_val;
17251 }
17252
17253 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
17254         LDKOpenChannel this_ptr_conv;
17255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17256         this_ptr_conv.is_owned = false;
17257         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17258 }
17259
17260 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
17261         LDKOpenChannel this_ptr_conv;
17262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17263         this_ptr_conv.is_owned = false;
17264         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17265         return ret_val;
17266 }
17267
17268 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
17269         LDKOpenChannel this_ptr_conv;
17270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17271         this_ptr_conv.is_owned = false;
17272         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17273 }
17274
17275 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
17276         LDKOpenChannel this_ptr_conv;
17277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17278         this_ptr_conv.is_owned = false;
17279         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17280         return ret_val;
17281 }
17282
17283 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
17284         LDKOpenChannel this_ptr_conv;
17285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17286         this_ptr_conv.is_owned = false;
17287         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17288 }
17289
17290 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
17291         LDKOpenChannel this_ptr_conv;
17292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17293         this_ptr_conv.is_owned = false;
17294         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17295         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
17296         return ret_arr;
17297 }
17298
17299 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
17300         LDKOpenChannel this_ptr_conv;
17301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17302         this_ptr_conv.is_owned = false;
17303         LDKPublicKey val_ref;
17304         CHECK(*((uint32_t*)val) == 33);
17305         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17306         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17307 }
17308
17309 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
17310         LDKOpenChannel this_ptr_conv;
17311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17312         this_ptr_conv.is_owned = false;
17313         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17314         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
17315         return ret_arr;
17316 }
17317
17318 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
17319         LDKOpenChannel this_ptr_conv;
17320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17321         this_ptr_conv.is_owned = false;
17322         LDKPublicKey val_ref;
17323         CHECK(*((uint32_t*)val) == 33);
17324         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17325         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17326 }
17327
17328 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
17329         LDKOpenChannel this_ptr_conv;
17330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17331         this_ptr_conv.is_owned = false;
17332         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17333         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
17334         return ret_arr;
17335 }
17336
17337 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
17338         LDKOpenChannel this_ptr_conv;
17339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17340         this_ptr_conv.is_owned = false;
17341         LDKPublicKey val_ref;
17342         CHECK(*((uint32_t*)val) == 33);
17343         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17344         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17345 }
17346
17347 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
17348         LDKOpenChannel this_ptr_conv;
17349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17350         this_ptr_conv.is_owned = false;
17351         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17352         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
17353         return ret_arr;
17354 }
17355
17356 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
17357         LDKOpenChannel this_ptr_conv;
17358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17359         this_ptr_conv.is_owned = false;
17360         LDKPublicKey val_ref;
17361         CHECK(*((uint32_t*)val) == 33);
17362         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17363         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17364 }
17365
17366 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
17367         LDKOpenChannel this_ptr_conv;
17368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17369         this_ptr_conv.is_owned = false;
17370         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17371         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
17372         return ret_arr;
17373 }
17374
17375 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
17376         LDKOpenChannel this_ptr_conv;
17377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17378         this_ptr_conv.is_owned = false;
17379         LDKPublicKey val_ref;
17380         CHECK(*((uint32_t*)val) == 33);
17381         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17382         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17383 }
17384
17385 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
17386         LDKOpenChannel this_ptr_conv;
17387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17388         this_ptr_conv.is_owned = false;
17389         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17390         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17391         return ret_arr;
17392 }
17393
17394 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17395         LDKOpenChannel this_ptr_conv;
17396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17397         this_ptr_conv.is_owned = false;
17398         LDKPublicKey val_ref;
17399         CHECK(*((uint32_t*)val) == 33);
17400         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17401         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17402 }
17403
17404 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
17405         LDKOpenChannel this_ptr_conv;
17406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17407         this_ptr_conv.is_owned = false;
17408         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17409         return ret_val;
17410 }
17411
17412 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
17413         LDKOpenChannel this_ptr_conv;
17414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17415         this_ptr_conv.is_owned = false;
17416         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17417 }
17418
17419 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
17420         LDKOpenChannel orig_conv;
17421         orig_conv.inner = (void*)(orig & (~1));
17422         orig_conv.is_owned = false;
17423         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17424         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17425         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17426         uint64_t ret_ref = (uint64_t)ret_var.inner;
17427         if (ret_var.is_owned) {
17428                 ret_ref |= 1;
17429         }
17430         return ret_ref;
17431 }
17432
17433 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
17434         LDKAcceptChannel this_obj_conv;
17435         this_obj_conv.inner = (void*)(this_obj & (~1));
17436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17437         AcceptChannel_free(this_obj_conv);
17438 }
17439
17440 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
17441         LDKAcceptChannel this_ptr_conv;
17442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17443         this_ptr_conv.is_owned = false;
17444         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17445         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
17446         return ret_arr;
17447 }
17448
17449 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
17450         LDKAcceptChannel this_ptr_conv;
17451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17452         this_ptr_conv.is_owned = false;
17453         LDKThirtyTwoBytes val_ref;
17454         CHECK(*((uint32_t*)val) == 32);
17455         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17456         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17457 }
17458
17459 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
17460         LDKAcceptChannel this_ptr_conv;
17461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17462         this_ptr_conv.is_owned = false;
17463         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17464         return ret_val;
17465 }
17466
17467 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
17468         LDKAcceptChannel this_ptr_conv;
17469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17470         this_ptr_conv.is_owned = false;
17471         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17472 }
17473
17474 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
17475         LDKAcceptChannel this_ptr_conv;
17476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17477         this_ptr_conv.is_owned = false;
17478         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17479         return ret_val;
17480 }
17481
17482 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
17483         LDKAcceptChannel this_ptr_conv;
17484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17485         this_ptr_conv.is_owned = false;
17486         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17487 }
17488
17489 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
17490         LDKAcceptChannel this_ptr_conv;
17491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17492         this_ptr_conv.is_owned = false;
17493         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17494         return ret_val;
17495 }
17496
17497 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
17498         LDKAcceptChannel this_ptr_conv;
17499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17500         this_ptr_conv.is_owned = false;
17501         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17502 }
17503
17504 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
17505         LDKAcceptChannel this_ptr_conv;
17506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17507         this_ptr_conv.is_owned = false;
17508         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17509         return ret_val;
17510 }
17511
17512 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17513         LDKAcceptChannel this_ptr_conv;
17514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17515         this_ptr_conv.is_owned = false;
17516         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17517 }
17518
17519 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
17520         LDKAcceptChannel this_ptr_conv;
17521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17522         this_ptr_conv.is_owned = false;
17523         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
17524         return ret_val;
17525 }
17526
17527 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
17528         LDKAcceptChannel this_ptr_conv;
17529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17530         this_ptr_conv.is_owned = false;
17531         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
17532 }
17533
17534 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
17535         LDKAcceptChannel this_ptr_conv;
17536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17537         this_ptr_conv.is_owned = false;
17538         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
17539         return ret_val;
17540 }
17541
17542 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
17543         LDKAcceptChannel this_ptr_conv;
17544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17545         this_ptr_conv.is_owned = false;
17546         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
17547 }
17548
17549 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
17550         LDKAcceptChannel this_ptr_conv;
17551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17552         this_ptr_conv.is_owned = false;
17553         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
17554         return ret_val;
17555 }
17556
17557 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
17558         LDKAcceptChannel this_ptr_conv;
17559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17560         this_ptr_conv.is_owned = false;
17561         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17562 }
17563
17564 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
17565         LDKAcceptChannel this_ptr_conv;
17566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17567         this_ptr_conv.is_owned = false;
17568         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17569         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
17570         return ret_arr;
17571 }
17572
17573 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
17574         LDKAcceptChannel this_ptr_conv;
17575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17576         this_ptr_conv.is_owned = false;
17577         LDKPublicKey val_ref;
17578         CHECK(*((uint32_t*)val) == 33);
17579         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17580         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17581 }
17582
17583 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
17584         LDKAcceptChannel this_ptr_conv;
17585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17586         this_ptr_conv.is_owned = false;
17587         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17588         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
17589         return ret_arr;
17590 }
17591
17592 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
17593         LDKAcceptChannel this_ptr_conv;
17594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17595         this_ptr_conv.is_owned = false;
17596         LDKPublicKey val_ref;
17597         CHECK(*((uint32_t*)val) == 33);
17598         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17599         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17600 }
17601
17602 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
17603         LDKAcceptChannel this_ptr_conv;
17604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17605         this_ptr_conv.is_owned = false;
17606         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17607         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
17608         return ret_arr;
17609 }
17610
17611 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
17612         LDKAcceptChannel this_ptr_conv;
17613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17614         this_ptr_conv.is_owned = false;
17615         LDKPublicKey val_ref;
17616         CHECK(*((uint32_t*)val) == 33);
17617         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17618         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17619 }
17620
17621 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
17622         LDKAcceptChannel this_ptr_conv;
17623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17624         this_ptr_conv.is_owned = false;
17625         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17626         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
17627         return ret_arr;
17628 }
17629
17630 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
17631         LDKAcceptChannel this_ptr_conv;
17632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17633         this_ptr_conv.is_owned = false;
17634         LDKPublicKey val_ref;
17635         CHECK(*((uint32_t*)val) == 33);
17636         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17637         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17638 }
17639
17640 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
17641         LDKAcceptChannel this_ptr_conv;
17642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17643         this_ptr_conv.is_owned = false;
17644         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17645         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
17646         return ret_arr;
17647 }
17648
17649 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
17650         LDKAcceptChannel this_ptr_conv;
17651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17652         this_ptr_conv.is_owned = false;
17653         LDKPublicKey val_ref;
17654         CHECK(*((uint32_t*)val) == 33);
17655         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17656         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17657 }
17658
17659 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
17660         LDKAcceptChannel this_ptr_conv;
17661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17662         this_ptr_conv.is_owned = false;
17663         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17664         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17665         return ret_arr;
17666 }
17667
17668 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17669         LDKAcceptChannel this_ptr_conv;
17670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17671         this_ptr_conv.is_owned = false;
17672         LDKPublicKey val_ref;
17673         CHECK(*((uint32_t*)val) == 33);
17674         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17675         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17676 }
17677
17678 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
17679         LDKAcceptChannel orig_conv;
17680         orig_conv.inner = (void*)(orig & (~1));
17681         orig_conv.is_owned = false;
17682         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17685         uint64_t ret_ref = (uint64_t)ret_var.inner;
17686         if (ret_var.is_owned) {
17687                 ret_ref |= 1;
17688         }
17689         return ret_ref;
17690 }
17691
17692 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
17693         LDKFundingCreated this_obj_conv;
17694         this_obj_conv.inner = (void*)(this_obj & (~1));
17695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17696         FundingCreated_free(this_obj_conv);
17697 }
17698
17699 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
17700         LDKFundingCreated this_ptr_conv;
17701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17702         this_ptr_conv.is_owned = false;
17703         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17704         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
17705         return ret_arr;
17706 }
17707
17708 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
17709         LDKFundingCreated this_ptr_conv;
17710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17711         this_ptr_conv.is_owned = false;
17712         LDKThirtyTwoBytes val_ref;
17713         CHECK(*((uint32_t*)val) == 32);
17714         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17715         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17716 }
17717
17718 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
17719         LDKFundingCreated this_ptr_conv;
17720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17721         this_ptr_conv.is_owned = false;
17722         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17723         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
17724         return ret_arr;
17725 }
17726
17727 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
17728         LDKFundingCreated this_ptr_conv;
17729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17730         this_ptr_conv.is_owned = false;
17731         LDKThirtyTwoBytes val_ref;
17732         CHECK(*((uint32_t*)val) == 32);
17733         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17734         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17735 }
17736
17737 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
17738         LDKFundingCreated this_ptr_conv;
17739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17740         this_ptr_conv.is_owned = false;
17741         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17742         return ret_val;
17743 }
17744
17745 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
17746         LDKFundingCreated this_ptr_conv;
17747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17748         this_ptr_conv.is_owned = false;
17749         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17750 }
17751
17752 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
17753         LDKFundingCreated this_ptr_conv;
17754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17755         this_ptr_conv.is_owned = false;
17756         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17757         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
17758         return ret_arr;
17759 }
17760
17761 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
17762         LDKFundingCreated this_ptr_conv;
17763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17764         this_ptr_conv.is_owned = false;
17765         LDKSignature val_ref;
17766         CHECK(*((uint32_t*)val) == 64);
17767         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17768         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17769 }
17770
17771 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) {
17772         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17773         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
17774         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
17775         LDKThirtyTwoBytes funding_txid_arg_ref;
17776         CHECK(*((uint32_t*)funding_txid_arg) == 32);
17777         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
17778         LDKSignature signature_arg_ref;
17779         CHECK(*((uint32_t*)signature_arg) == 64);
17780         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17781         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17784         uint64_t ret_ref = (uint64_t)ret_var.inner;
17785         if (ret_var.is_owned) {
17786                 ret_ref |= 1;
17787         }
17788         return ret_ref;
17789 }
17790
17791 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
17792         LDKFundingCreated orig_conv;
17793         orig_conv.inner = (void*)(orig & (~1));
17794         orig_conv.is_owned = false;
17795         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17798         uint64_t ret_ref = (uint64_t)ret_var.inner;
17799         if (ret_var.is_owned) {
17800                 ret_ref |= 1;
17801         }
17802         return ret_ref;
17803 }
17804
17805 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
17806         LDKFundingSigned this_obj_conv;
17807         this_obj_conv.inner = (void*)(this_obj & (~1));
17808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17809         FundingSigned_free(this_obj_conv);
17810 }
17811
17812 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
17813         LDKFundingSigned this_ptr_conv;
17814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17815         this_ptr_conv.is_owned = false;
17816         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17817         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
17818         return ret_arr;
17819 }
17820
17821 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17822         LDKFundingSigned this_ptr_conv;
17823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17824         this_ptr_conv.is_owned = false;
17825         LDKThirtyTwoBytes val_ref;
17826         CHECK(*((uint32_t*)val) == 32);
17827         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17828         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17829 }
17830
17831 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
17832         LDKFundingSigned this_ptr_conv;
17833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17834         this_ptr_conv.is_owned = false;
17835         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17836         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
17837         return ret_arr;
17838 }
17839
17840 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17841         LDKFundingSigned this_ptr_conv;
17842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17843         this_ptr_conv.is_owned = false;
17844         LDKSignature val_ref;
17845         CHECK(*((uint32_t*)val) == 64);
17846         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17847         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17848 }
17849
17850 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
17851         LDKThirtyTwoBytes channel_id_arg_ref;
17852         CHECK(*((uint32_t*)channel_id_arg) == 32);
17853         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17854         LDKSignature signature_arg_ref;
17855         CHECK(*((uint32_t*)signature_arg) == 64);
17856         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17857         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17860         uint64_t ret_ref = (uint64_t)ret_var.inner;
17861         if (ret_var.is_owned) {
17862                 ret_ref |= 1;
17863         }
17864         return ret_ref;
17865 }
17866
17867 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
17868         LDKFundingSigned orig_conv;
17869         orig_conv.inner = (void*)(orig & (~1));
17870         orig_conv.is_owned = false;
17871         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17874         uint64_t ret_ref = (uint64_t)ret_var.inner;
17875         if (ret_var.is_owned) {
17876                 ret_ref |= 1;
17877         }
17878         return ret_ref;
17879 }
17880
17881 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
17882         LDKFundingLocked this_obj_conv;
17883         this_obj_conv.inner = (void*)(this_obj & (~1));
17884         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17885         FundingLocked_free(this_obj_conv);
17886 }
17887
17888 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
17889         LDKFundingLocked this_ptr_conv;
17890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17891         this_ptr_conv.is_owned = false;
17892         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17893         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
17894         return ret_arr;
17895 }
17896
17897 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17898         LDKFundingLocked this_ptr_conv;
17899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17900         this_ptr_conv.is_owned = false;
17901         LDKThirtyTwoBytes val_ref;
17902         CHECK(*((uint32_t*)val) == 32);
17903         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17904         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17905 }
17906
17907 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
17908         LDKFundingLocked this_ptr_conv;
17909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17910         this_ptr_conv.is_owned = false;
17911         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17912         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17913         return ret_arr;
17914 }
17915
17916 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17917         LDKFundingLocked this_ptr_conv;
17918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17919         this_ptr_conv.is_owned = false;
17920         LDKPublicKey val_ref;
17921         CHECK(*((uint32_t*)val) == 33);
17922         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17923         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17924 }
17925
17926 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
17927         LDKThirtyTwoBytes channel_id_arg_ref;
17928         CHECK(*((uint32_t*)channel_id_arg) == 32);
17929         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17930         LDKPublicKey next_per_commitment_point_arg_ref;
17931         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
17932         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
17933         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17936         uint64_t ret_ref = (uint64_t)ret_var.inner;
17937         if (ret_var.is_owned) {
17938                 ret_ref |= 1;
17939         }
17940         return ret_ref;
17941 }
17942
17943 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
17944         LDKFundingLocked orig_conv;
17945         orig_conv.inner = (void*)(orig & (~1));
17946         orig_conv.is_owned = false;
17947         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17950         uint64_t ret_ref = (uint64_t)ret_var.inner;
17951         if (ret_var.is_owned) {
17952                 ret_ref |= 1;
17953         }
17954         return ret_ref;
17955 }
17956
17957 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
17958         LDKShutdown this_obj_conv;
17959         this_obj_conv.inner = (void*)(this_obj & (~1));
17960         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17961         Shutdown_free(this_obj_conv);
17962 }
17963
17964 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
17965         LDKShutdown this_ptr_conv;
17966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17967         this_ptr_conv.is_owned = false;
17968         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17969         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
17970         return ret_arr;
17971 }
17972
17973 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17974         LDKShutdown this_ptr_conv;
17975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17976         this_ptr_conv.is_owned = false;
17977         LDKThirtyTwoBytes val_ref;
17978         CHECK(*((uint32_t*)val) == 32);
17979         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17980         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17981 }
17982
17983 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
17984         LDKShutdown this_ptr_conv;
17985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17986         this_ptr_conv.is_owned = false;
17987         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17988         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17989         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17990         return ret_arr;
17991 }
17992
17993 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
17994         LDKShutdown this_ptr_conv;
17995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17996         this_ptr_conv.is_owned = false;
17997         LDKCVec_u8Z val_ref;
17998         val_ref.datalen = *((uint32_t*)val);
17999         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18000         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
18001         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18002 }
18003
18004 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18005         LDKThirtyTwoBytes channel_id_arg_ref;
18006         CHECK(*((uint32_t*)channel_id_arg) == 32);
18007         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18008         LDKCVec_u8Z scriptpubkey_arg_ref;
18009         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
18010         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18011         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
18012         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18015         uint64_t ret_ref = (uint64_t)ret_var.inner;
18016         if (ret_var.is_owned) {
18017                 ret_ref |= 1;
18018         }
18019         return ret_ref;
18020 }
18021
18022 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
18023         LDKShutdown orig_conv;
18024         orig_conv.inner = (void*)(orig & (~1));
18025         orig_conv.is_owned = false;
18026         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18029         uint64_t ret_ref = (uint64_t)ret_var.inner;
18030         if (ret_var.is_owned) {
18031                 ret_ref |= 1;
18032         }
18033         return ret_ref;
18034 }
18035
18036 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
18037         LDKClosingSignedFeeRange this_obj_conv;
18038         this_obj_conv.inner = (void*)(this_obj & (~1));
18039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18040         ClosingSignedFeeRange_free(this_obj_conv);
18041 }
18042
18043 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
18044         LDKClosingSignedFeeRange this_ptr_conv;
18045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18046         this_ptr_conv.is_owned = false;
18047         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
18048         return ret_val;
18049 }
18050
18051 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
18052         LDKClosingSignedFeeRange this_ptr_conv;
18053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18054         this_ptr_conv.is_owned = false;
18055         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
18056 }
18057
18058 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
18059         LDKClosingSignedFeeRange this_ptr_conv;
18060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18061         this_ptr_conv.is_owned = false;
18062         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
18063         return ret_val;
18064 }
18065
18066 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
18067         LDKClosingSignedFeeRange this_ptr_conv;
18068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18069         this_ptr_conv.is_owned = false;
18070         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
18071 }
18072
18073 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
18074         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
18075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18077         uint64_t ret_ref = (uint64_t)ret_var.inner;
18078         if (ret_var.is_owned) {
18079                 ret_ref |= 1;
18080         }
18081         return ret_ref;
18082 }
18083
18084 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
18085         LDKClosingSignedFeeRange orig_conv;
18086         orig_conv.inner = (void*)(orig & (~1));
18087         orig_conv.is_owned = false;
18088         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
18089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18091         uint64_t ret_ref = (uint64_t)ret_var.inner;
18092         if (ret_var.is_owned) {
18093                 ret_ref |= 1;
18094         }
18095         return ret_ref;
18096 }
18097
18098 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
18099         LDKClosingSigned this_obj_conv;
18100         this_obj_conv.inner = (void*)(this_obj & (~1));
18101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18102         ClosingSigned_free(this_obj_conv);
18103 }
18104
18105 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
18106         LDKClosingSigned this_ptr_conv;
18107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18108         this_ptr_conv.is_owned = false;
18109         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18110         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
18111         return ret_arr;
18112 }
18113
18114 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18115         LDKClosingSigned this_ptr_conv;
18116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18117         this_ptr_conv.is_owned = false;
18118         LDKThirtyTwoBytes val_ref;
18119         CHECK(*((uint32_t*)val) == 32);
18120         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18121         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18122 }
18123
18124 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
18125         LDKClosingSigned this_ptr_conv;
18126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18127         this_ptr_conv.is_owned = false;
18128         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18129         return ret_val;
18130 }
18131
18132 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
18133         LDKClosingSigned this_ptr_conv;
18134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18135         this_ptr_conv.is_owned = false;
18136         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
18137 }
18138
18139 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
18140         LDKClosingSigned this_ptr_conv;
18141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18142         this_ptr_conv.is_owned = false;
18143         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18144         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
18145         return ret_arr;
18146 }
18147
18148 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
18149         LDKClosingSigned this_ptr_conv;
18150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18151         this_ptr_conv.is_owned = false;
18152         LDKSignature val_ref;
18153         CHECK(*((uint32_t*)val) == 64);
18154         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18155         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
18156 }
18157
18158 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
18159         LDKClosingSigned this_ptr_conv;
18160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18161         this_ptr_conv.is_owned = false;
18162         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
18163         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18164         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18165         uint64_t ret_ref = (uint64_t)ret_var.inner;
18166         if (ret_var.is_owned) {
18167                 ret_ref |= 1;
18168         }
18169         return ret_ref;
18170 }
18171
18172 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
18173         LDKClosingSigned this_ptr_conv;
18174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18175         this_ptr_conv.is_owned = false;
18176         LDKClosingSignedFeeRange val_conv;
18177         val_conv.inner = (void*)(val & (~1));
18178         val_conv.is_owned = (val & 1) || (val == 0);
18179         val_conv = ClosingSignedFeeRange_clone(&val_conv);
18180         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
18181 }
18182
18183 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) {
18184         LDKThirtyTwoBytes channel_id_arg_ref;
18185         CHECK(*((uint32_t*)channel_id_arg) == 32);
18186         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18187         LDKSignature signature_arg_ref;
18188         CHECK(*((uint32_t*)signature_arg) == 64);
18189         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
18190         LDKClosingSignedFeeRange fee_range_arg_conv;
18191         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
18192         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
18193         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
18194         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
18195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18197         uint64_t ret_ref = (uint64_t)ret_var.inner;
18198         if (ret_var.is_owned) {
18199                 ret_ref |= 1;
18200         }
18201         return ret_ref;
18202 }
18203
18204 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
18205         LDKClosingSigned orig_conv;
18206         orig_conv.inner = (void*)(orig & (~1));
18207         orig_conv.is_owned = false;
18208         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18211         uint64_t ret_ref = (uint64_t)ret_var.inner;
18212         if (ret_var.is_owned) {
18213                 ret_ref |= 1;
18214         }
18215         return ret_ref;
18216 }
18217
18218 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
18219         LDKUpdateAddHTLC this_obj_conv;
18220         this_obj_conv.inner = (void*)(this_obj & (~1));
18221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18222         UpdateAddHTLC_free(this_obj_conv);
18223 }
18224
18225 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
18226         LDKUpdateAddHTLC this_ptr_conv;
18227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18228         this_ptr_conv.is_owned = false;
18229         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18230         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
18231         return ret_arr;
18232 }
18233
18234 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18235         LDKUpdateAddHTLC this_ptr_conv;
18236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18237         this_ptr_conv.is_owned = false;
18238         LDKThirtyTwoBytes val_ref;
18239         CHECK(*((uint32_t*)val) == 32);
18240         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18241         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18242 }
18243
18244 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
18245         LDKUpdateAddHTLC this_ptr_conv;
18246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18247         this_ptr_conv.is_owned = false;
18248         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18249         return ret_val;
18250 }
18251
18252 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
18253         LDKUpdateAddHTLC this_ptr_conv;
18254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18255         this_ptr_conv.is_owned = false;
18256         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18257 }
18258
18259 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
18260         LDKUpdateAddHTLC this_ptr_conv;
18261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18262         this_ptr_conv.is_owned = false;
18263         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18264         return ret_val;
18265 }
18266
18267 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
18268         LDKUpdateAddHTLC this_ptr_conv;
18269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18270         this_ptr_conv.is_owned = false;
18271         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18272 }
18273
18274 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
18275         LDKUpdateAddHTLC this_ptr_conv;
18276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18277         this_ptr_conv.is_owned = false;
18278         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18279         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
18280         return ret_arr;
18281 }
18282
18283 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
18284         LDKUpdateAddHTLC this_ptr_conv;
18285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18286         this_ptr_conv.is_owned = false;
18287         LDKThirtyTwoBytes val_ref;
18288         CHECK(*((uint32_t*)val) == 32);
18289         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18290         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18291 }
18292
18293 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
18294         LDKUpdateAddHTLC this_ptr_conv;
18295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18296         this_ptr_conv.is_owned = false;
18297         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18298         return ret_val;
18299 }
18300
18301 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
18302         LDKUpdateAddHTLC this_ptr_conv;
18303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18304         this_ptr_conv.is_owned = false;
18305         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18306 }
18307
18308 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
18309         LDKUpdateAddHTLC orig_conv;
18310         orig_conv.inner = (void*)(orig & (~1));
18311         orig_conv.is_owned = false;
18312         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18315         uint64_t ret_ref = (uint64_t)ret_var.inner;
18316         if (ret_var.is_owned) {
18317                 ret_ref |= 1;
18318         }
18319         return ret_ref;
18320 }
18321
18322 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
18323         LDKUpdateFulfillHTLC this_obj_conv;
18324         this_obj_conv.inner = (void*)(this_obj & (~1));
18325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18326         UpdateFulfillHTLC_free(this_obj_conv);
18327 }
18328
18329 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
18330         LDKUpdateFulfillHTLC this_ptr_conv;
18331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18332         this_ptr_conv.is_owned = false;
18333         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18334         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
18335         return ret_arr;
18336 }
18337
18338 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18339         LDKUpdateFulfillHTLC this_ptr_conv;
18340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18341         this_ptr_conv.is_owned = false;
18342         LDKThirtyTwoBytes val_ref;
18343         CHECK(*((uint32_t*)val) == 32);
18344         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18345         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18346 }
18347
18348 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
18349         LDKUpdateFulfillHTLC this_ptr_conv;
18350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18351         this_ptr_conv.is_owned = false;
18352         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18353         return ret_val;
18354 }
18355
18356 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
18357         LDKUpdateFulfillHTLC this_ptr_conv;
18358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18359         this_ptr_conv.is_owned = false;
18360         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18361 }
18362
18363 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
18364         LDKUpdateFulfillHTLC this_ptr_conv;
18365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18366         this_ptr_conv.is_owned = false;
18367         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18368         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
18369         return ret_arr;
18370 }
18371
18372 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
18373         LDKUpdateFulfillHTLC this_ptr_conv;
18374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18375         this_ptr_conv.is_owned = false;
18376         LDKThirtyTwoBytes val_ref;
18377         CHECK(*((uint32_t*)val) == 32);
18378         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18379         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18380 }
18381
18382 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
18383         LDKThirtyTwoBytes channel_id_arg_ref;
18384         CHECK(*((uint32_t*)channel_id_arg) == 32);
18385         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18386         LDKThirtyTwoBytes payment_preimage_arg_ref;
18387         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
18388         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
18389         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18392         uint64_t ret_ref = (uint64_t)ret_var.inner;
18393         if (ret_var.is_owned) {
18394                 ret_ref |= 1;
18395         }
18396         return ret_ref;
18397 }
18398
18399 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
18400         LDKUpdateFulfillHTLC orig_conv;
18401         orig_conv.inner = (void*)(orig & (~1));
18402         orig_conv.is_owned = false;
18403         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18404         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18405         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18406         uint64_t ret_ref = (uint64_t)ret_var.inner;
18407         if (ret_var.is_owned) {
18408                 ret_ref |= 1;
18409         }
18410         return ret_ref;
18411 }
18412
18413 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
18414         LDKUpdateFailHTLC this_obj_conv;
18415         this_obj_conv.inner = (void*)(this_obj & (~1));
18416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18417         UpdateFailHTLC_free(this_obj_conv);
18418 }
18419
18420 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
18421         LDKUpdateFailHTLC this_ptr_conv;
18422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18423         this_ptr_conv.is_owned = false;
18424         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18425         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
18426         return ret_arr;
18427 }
18428
18429 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18430         LDKUpdateFailHTLC this_ptr_conv;
18431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18432         this_ptr_conv.is_owned = false;
18433         LDKThirtyTwoBytes val_ref;
18434         CHECK(*((uint32_t*)val) == 32);
18435         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18436         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18437 }
18438
18439 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
18440         LDKUpdateFailHTLC this_ptr_conv;
18441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18442         this_ptr_conv.is_owned = false;
18443         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18444         return ret_val;
18445 }
18446
18447 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
18448         LDKUpdateFailHTLC this_ptr_conv;
18449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18450         this_ptr_conv.is_owned = false;
18451         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18452 }
18453
18454 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
18455         LDKUpdateFailHTLC orig_conv;
18456         orig_conv.inner = (void*)(orig & (~1));
18457         orig_conv.is_owned = false;
18458         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_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_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
18469         LDKUpdateFailMalformedHTLC this_obj_conv;
18470         this_obj_conv.inner = (void*)(this_obj & (~1));
18471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18472         UpdateFailMalformedHTLC_free(this_obj_conv);
18473 }
18474
18475 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
18476         LDKUpdateFailMalformedHTLC this_ptr_conv;
18477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18478         this_ptr_conv.is_owned = false;
18479         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18480         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
18481         return ret_arr;
18482 }
18483
18484 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18485         LDKUpdateFailMalformedHTLC this_ptr_conv;
18486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18487         this_ptr_conv.is_owned = false;
18488         LDKThirtyTwoBytes val_ref;
18489         CHECK(*((uint32_t*)val) == 32);
18490         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18491         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18492 }
18493
18494 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
18495         LDKUpdateFailMalformedHTLC this_ptr_conv;
18496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18497         this_ptr_conv.is_owned = false;
18498         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18499         return ret_val;
18500 }
18501
18502 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
18503         LDKUpdateFailMalformedHTLC this_ptr_conv;
18504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18505         this_ptr_conv.is_owned = false;
18506         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18507 }
18508
18509 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
18510         LDKUpdateFailMalformedHTLC this_ptr_conv;
18511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18512         this_ptr_conv.is_owned = false;
18513         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18514         return ret_val;
18515 }
18516
18517 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
18518         LDKUpdateFailMalformedHTLC this_ptr_conv;
18519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18520         this_ptr_conv.is_owned = false;
18521         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18522 }
18523
18524 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
18525         LDKUpdateFailMalformedHTLC orig_conv;
18526         orig_conv.inner = (void*)(orig & (~1));
18527         orig_conv.is_owned = false;
18528         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18531         uint64_t ret_ref = (uint64_t)ret_var.inner;
18532         if (ret_var.is_owned) {
18533                 ret_ref |= 1;
18534         }
18535         return ret_ref;
18536 }
18537
18538 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
18539         LDKCommitmentSigned this_obj_conv;
18540         this_obj_conv.inner = (void*)(this_obj & (~1));
18541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18542         CommitmentSigned_free(this_obj_conv);
18543 }
18544
18545 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
18546         LDKCommitmentSigned this_ptr_conv;
18547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18548         this_ptr_conv.is_owned = false;
18549         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18550         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
18551         return ret_arr;
18552 }
18553
18554 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18555         LDKCommitmentSigned this_ptr_conv;
18556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18557         this_ptr_conv.is_owned = false;
18558         LDKThirtyTwoBytes val_ref;
18559         CHECK(*((uint32_t*)val) == 32);
18560         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18561         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18562 }
18563
18564 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
18565         LDKCommitmentSigned this_ptr_conv;
18566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18567         this_ptr_conv.is_owned = false;
18568         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18569         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
18570         return ret_arr;
18571 }
18572
18573 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
18574         LDKCommitmentSigned this_ptr_conv;
18575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18576         this_ptr_conv.is_owned = false;
18577         LDKSignature val_ref;
18578         CHECK(*((uint32_t*)val) == 64);
18579         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18580         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18581 }
18582
18583 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
18584         LDKCommitmentSigned this_ptr_conv;
18585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18586         this_ptr_conv.is_owned = false;
18587         LDKCVec_SignatureZ val_constr;
18588         val_constr.datalen = *((uint32_t*)val);
18589         if (val_constr.datalen > 0)
18590                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18591         else
18592                 val_constr.data = NULL;
18593         int8_tArray* val_vals = (int8_tArray*)(val + 4);
18594         for (size_t m = 0; m < val_constr.datalen; m++) {
18595                 int8_tArray val_conv_12 = val_vals[m];
18596                 LDKSignature val_conv_12_ref;
18597                 CHECK(*((uint32_t*)val_conv_12) == 64);
18598                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
18599                 val_constr.data[m] = val_conv_12_ref;
18600         }
18601         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18602 }
18603
18604 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
18605         LDKThirtyTwoBytes channel_id_arg_ref;
18606         CHECK(*((uint32_t*)channel_id_arg) == 32);
18607         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18608         LDKSignature signature_arg_ref;
18609         CHECK(*((uint32_t*)signature_arg) == 64);
18610         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
18611         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18612         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
18613         if (htlc_signatures_arg_constr.datalen > 0)
18614                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18615         else
18616                 htlc_signatures_arg_constr.data = NULL;
18617         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
18618         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
18619                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
18620                 LDKSignature htlc_signatures_arg_conv_12_ref;
18621                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
18622                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
18623                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
18624         }
18625         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18628         uint64_t ret_ref = (uint64_t)ret_var.inner;
18629         if (ret_var.is_owned) {
18630                 ret_ref |= 1;
18631         }
18632         return ret_ref;
18633 }
18634
18635 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
18636         LDKCommitmentSigned orig_conv;
18637         orig_conv.inner = (void*)(orig & (~1));
18638         orig_conv.is_owned = false;
18639         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18640         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18641         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18642         uint64_t ret_ref = (uint64_t)ret_var.inner;
18643         if (ret_var.is_owned) {
18644                 ret_ref |= 1;
18645         }
18646         return ret_ref;
18647 }
18648
18649 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
18650         LDKRevokeAndACK this_obj_conv;
18651         this_obj_conv.inner = (void*)(this_obj & (~1));
18652         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18653         RevokeAndACK_free(this_obj_conv);
18654 }
18655
18656 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
18657         LDKRevokeAndACK this_ptr_conv;
18658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18659         this_ptr_conv.is_owned = false;
18660         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18661         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
18662         return ret_arr;
18663 }
18664
18665 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18666         LDKRevokeAndACK this_ptr_conv;
18667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18668         this_ptr_conv.is_owned = false;
18669         LDKThirtyTwoBytes val_ref;
18670         CHECK(*((uint32_t*)val) == 32);
18671         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18672         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18673 }
18674
18675 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
18676         LDKRevokeAndACK this_ptr_conv;
18677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18678         this_ptr_conv.is_owned = false;
18679         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18680         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
18681         return ret_arr;
18682 }
18683
18684 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
18685         LDKRevokeAndACK this_ptr_conv;
18686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18687         this_ptr_conv.is_owned = false;
18688         LDKThirtyTwoBytes val_ref;
18689         CHECK(*((uint32_t*)val) == 32);
18690         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18691         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18692 }
18693
18694 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
18695         LDKRevokeAndACK this_ptr_conv;
18696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18697         this_ptr_conv.is_owned = false;
18698         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18699         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18700         return ret_arr;
18701 }
18702
18703 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18704         LDKRevokeAndACK this_ptr_conv;
18705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18706         this_ptr_conv.is_owned = false;
18707         LDKPublicKey val_ref;
18708         CHECK(*((uint32_t*)val) == 33);
18709         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18710         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18711 }
18712
18713 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) {
18714         LDKThirtyTwoBytes channel_id_arg_ref;
18715         CHECK(*((uint32_t*)channel_id_arg) == 32);
18716         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18717         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18718         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
18719         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
18720         LDKPublicKey next_per_commitment_point_arg_ref;
18721         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
18722         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
18723         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18726         uint64_t ret_ref = (uint64_t)ret_var.inner;
18727         if (ret_var.is_owned) {
18728                 ret_ref |= 1;
18729         }
18730         return ret_ref;
18731 }
18732
18733 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
18734         LDKRevokeAndACK orig_conv;
18735         orig_conv.inner = (void*)(orig & (~1));
18736         orig_conv.is_owned = false;
18737         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18740         uint64_t ret_ref = (uint64_t)ret_var.inner;
18741         if (ret_var.is_owned) {
18742                 ret_ref |= 1;
18743         }
18744         return ret_ref;
18745 }
18746
18747 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
18748         LDKUpdateFee this_obj_conv;
18749         this_obj_conv.inner = (void*)(this_obj & (~1));
18750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18751         UpdateFee_free(this_obj_conv);
18752 }
18753
18754 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
18755         LDKUpdateFee this_ptr_conv;
18756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18757         this_ptr_conv.is_owned = false;
18758         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18759         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
18760         return ret_arr;
18761 }
18762
18763 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18764         LDKUpdateFee this_ptr_conv;
18765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18766         this_ptr_conv.is_owned = false;
18767         LDKThirtyTwoBytes val_ref;
18768         CHECK(*((uint32_t*)val) == 32);
18769         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18770         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18771 }
18772
18773 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
18774         LDKUpdateFee this_ptr_conv;
18775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18776         this_ptr_conv.is_owned = false;
18777         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18778         return ret_val;
18779 }
18780
18781 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
18782         LDKUpdateFee this_ptr_conv;
18783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18784         this_ptr_conv.is_owned = false;
18785         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18786 }
18787
18788 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
18789         LDKThirtyTwoBytes channel_id_arg_ref;
18790         CHECK(*((uint32_t*)channel_id_arg) == 32);
18791         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18792         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18795         uint64_t ret_ref = (uint64_t)ret_var.inner;
18796         if (ret_var.is_owned) {
18797                 ret_ref |= 1;
18798         }
18799         return ret_ref;
18800 }
18801
18802 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
18803         LDKUpdateFee orig_conv;
18804         orig_conv.inner = (void*)(orig & (~1));
18805         orig_conv.is_owned = false;
18806         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18807         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18808         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18809         uint64_t ret_ref = (uint64_t)ret_var.inner;
18810         if (ret_var.is_owned) {
18811                 ret_ref |= 1;
18812         }
18813         return ret_ref;
18814 }
18815
18816 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
18817         LDKDataLossProtect this_obj_conv;
18818         this_obj_conv.inner = (void*)(this_obj & (~1));
18819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18820         DataLossProtect_free(this_obj_conv);
18821 }
18822
18823 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
18824         LDKDataLossProtect this_ptr_conv;
18825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18826         this_ptr_conv.is_owned = false;
18827         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18828         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
18829         return ret_arr;
18830 }
18831
18832 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
18833         LDKDataLossProtect this_ptr_conv;
18834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18835         this_ptr_conv.is_owned = false;
18836         LDKThirtyTwoBytes val_ref;
18837         CHECK(*((uint32_t*)val) == 32);
18838         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18839         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18840 }
18841
18842 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
18843         LDKDataLossProtect this_ptr_conv;
18844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18845         this_ptr_conv.is_owned = false;
18846         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18847         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18848         return ret_arr;
18849 }
18850
18851 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18852         LDKDataLossProtect this_ptr_conv;
18853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18854         this_ptr_conv.is_owned = false;
18855         LDKPublicKey val_ref;
18856         CHECK(*((uint32_t*)val) == 33);
18857         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18858         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18859 }
18860
18861 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
18862         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18863         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
18864         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
18865         LDKPublicKey my_current_per_commitment_point_arg_ref;
18866         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
18867         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
18868         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18871         uint64_t ret_ref = (uint64_t)ret_var.inner;
18872         if (ret_var.is_owned) {
18873                 ret_ref |= 1;
18874         }
18875         return ret_ref;
18876 }
18877
18878 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
18879         LDKDataLossProtect orig_conv;
18880         orig_conv.inner = (void*)(orig & (~1));
18881         orig_conv.is_owned = false;
18882         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18885         uint64_t ret_ref = (uint64_t)ret_var.inner;
18886         if (ret_var.is_owned) {
18887                 ret_ref |= 1;
18888         }
18889         return ret_ref;
18890 }
18891
18892 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
18893         LDKChannelReestablish this_obj_conv;
18894         this_obj_conv.inner = (void*)(this_obj & (~1));
18895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18896         ChannelReestablish_free(this_obj_conv);
18897 }
18898
18899 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
18900         LDKChannelReestablish this_ptr_conv;
18901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18902         this_ptr_conv.is_owned = false;
18903         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18904         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
18905         return ret_arr;
18906 }
18907
18908 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18909         LDKChannelReestablish this_ptr_conv;
18910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18911         this_ptr_conv.is_owned = false;
18912         LDKThirtyTwoBytes val_ref;
18913         CHECK(*((uint32_t*)val) == 32);
18914         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18915         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18916 }
18917
18918 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
18919         LDKChannelReestablish this_ptr_conv;
18920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18921         this_ptr_conv.is_owned = false;
18922         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18923         return ret_val;
18924 }
18925
18926 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
18927         LDKChannelReestablish this_ptr_conv;
18928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18929         this_ptr_conv.is_owned = false;
18930         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18931 }
18932
18933 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
18934         LDKChannelReestablish this_ptr_conv;
18935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18936         this_ptr_conv.is_owned = false;
18937         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18938         return ret_val;
18939 }
18940
18941 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
18942         LDKChannelReestablish this_ptr_conv;
18943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18944         this_ptr_conv.is_owned = false;
18945         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18946 }
18947
18948 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
18949         LDKChannelReestablish orig_conv;
18950         orig_conv.inner = (void*)(orig & (~1));
18951         orig_conv.is_owned = false;
18952         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18953         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18954         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18955         uint64_t ret_ref = (uint64_t)ret_var.inner;
18956         if (ret_var.is_owned) {
18957                 ret_ref |= 1;
18958         }
18959         return ret_ref;
18960 }
18961
18962 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
18963         LDKAnnouncementSignatures this_obj_conv;
18964         this_obj_conv.inner = (void*)(this_obj & (~1));
18965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18966         AnnouncementSignatures_free(this_obj_conv);
18967 }
18968
18969 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
18970         LDKAnnouncementSignatures this_ptr_conv;
18971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18972         this_ptr_conv.is_owned = false;
18973         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18974         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
18975         return ret_arr;
18976 }
18977
18978 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18979         LDKAnnouncementSignatures this_ptr_conv;
18980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18981         this_ptr_conv.is_owned = false;
18982         LDKThirtyTwoBytes val_ref;
18983         CHECK(*((uint32_t*)val) == 32);
18984         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18985         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18986 }
18987
18988 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
18989         LDKAnnouncementSignatures this_ptr_conv;
18990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18991         this_ptr_conv.is_owned = false;
18992         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18993         return ret_val;
18994 }
18995
18996 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18997         LDKAnnouncementSignatures this_ptr_conv;
18998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18999         this_ptr_conv.is_owned = false;
19000         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19001 }
19002
19003 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
19004         LDKAnnouncementSignatures this_ptr_conv;
19005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19006         this_ptr_conv.is_owned = false;
19007         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19008         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
19009         return ret_arr;
19010 }
19011
19012 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
19013         LDKAnnouncementSignatures this_ptr_conv;
19014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19015         this_ptr_conv.is_owned = false;
19016         LDKSignature val_ref;
19017         CHECK(*((uint32_t*)val) == 64);
19018         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19019         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19020 }
19021
19022 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
19023         LDKAnnouncementSignatures this_ptr_conv;
19024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19025         this_ptr_conv.is_owned = false;
19026         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19027         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
19028         return ret_arr;
19029 }
19030
19031 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
19032         LDKAnnouncementSignatures this_ptr_conv;
19033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19034         this_ptr_conv.is_owned = false;
19035         LDKSignature val_ref;
19036         CHECK(*((uint32_t*)val) == 64);
19037         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19038         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19039 }
19040
19041 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) {
19042         LDKThirtyTwoBytes channel_id_arg_ref;
19043         CHECK(*((uint32_t*)channel_id_arg) == 32);
19044         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
19045         LDKSignature node_signature_arg_ref;
19046         CHECK(*((uint32_t*)node_signature_arg) == 64);
19047         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
19048         LDKSignature bitcoin_signature_arg_ref;
19049         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
19050         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
19051         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19054         uint64_t ret_ref = (uint64_t)ret_var.inner;
19055         if (ret_var.is_owned) {
19056                 ret_ref |= 1;
19057         }
19058         return ret_ref;
19059 }
19060
19061 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
19062         LDKAnnouncementSignatures orig_conv;
19063         orig_conv.inner = (void*)(orig & (~1));
19064         orig_conv.is_owned = false;
19065         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19068         uint64_t ret_ref = (uint64_t)ret_var.inner;
19069         if (ret_var.is_owned) {
19070                 ret_ref |= 1;
19071         }
19072         return ret_ref;
19073 }
19074
19075 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
19076         if ((this_ptr & 1) != 0) return;
19077         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19078         FREE((void*)this_ptr);
19079         NetAddress_free(this_ptr_conv);
19080 }
19081
19082 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
19083         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19084         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19085         *ret_copy = NetAddress_clone(orig_conv);
19086         uint64_t ret_ref = (uint64_t)ret_copy;
19087         return ret_ref;
19088 }
19089
19090 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
19091         LDKFourBytes addr_ref;
19092         CHECK(*((uint32_t*)addr) == 4);
19093         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
19094         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19095         *ret_copy = NetAddress_ipv4(addr_ref, port);
19096         uint64_t ret_ref = (uint64_t)ret_copy;
19097         return ret_ref;
19098 }
19099
19100 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
19101         LDKSixteenBytes addr_ref;
19102         CHECK(*((uint32_t*)addr) == 16);
19103         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
19104         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19105         *ret_copy = NetAddress_ipv6(addr_ref, port);
19106         uint64_t ret_ref = (uint64_t)ret_copy;
19107         return ret_ref;
19108 }
19109
19110 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
19111         LDKTenBytes addr_ref;
19112         CHECK(*((uint32_t*)addr) == 10);
19113         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
19114         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19115         *ret_copy = NetAddress_onion_v2(addr_ref, port);
19116         uint64_t ret_ref = (uint64_t)ret_copy;
19117         return ret_ref;
19118 }
19119
19120 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
19121         LDKThirtyTwoBytes ed25519_pubkey_ref;
19122         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
19123         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
19124         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19125         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
19126         uint64_t ret_ref = (uint64_t)ret_copy;
19127         return ret_ref;
19128 }
19129
19130 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
19131         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19132         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19133         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19134         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19135         CVec_u8Z_free(ret_var);
19136         return ret_arr;
19137 }
19138
19139 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
19140         LDKu8slice ser_ref;
19141         ser_ref.datalen = *((uint32_t*)ser);
19142         ser_ref.data = (int8_t*)(ser + 4);
19143         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
19144         *ret_conv = Result_read(ser_ref);
19145         return (uint64_t)ret_conv;
19146 }
19147
19148 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
19149         LDKu8slice ser_ref;
19150         ser_ref.datalen = *((uint32_t*)ser);
19151         ser_ref.data = (int8_t*)(ser + 4);
19152         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19153         *ret_conv = NetAddress_read(ser_ref);
19154         return (uint64_t)ret_conv;
19155 }
19156
19157 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
19158         LDKUnsignedNodeAnnouncement this_obj_conv;
19159         this_obj_conv.inner = (void*)(this_obj & (~1));
19160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19161         UnsignedNodeAnnouncement_free(this_obj_conv);
19162 }
19163
19164 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
19165         LDKUnsignedNodeAnnouncement this_ptr_conv;
19166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19167         this_ptr_conv.is_owned = false;
19168         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
19169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19171         uint64_t ret_ref = (uint64_t)ret_var.inner;
19172         if (ret_var.is_owned) {
19173                 ret_ref |= 1;
19174         }
19175         return ret_ref;
19176 }
19177
19178 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
19179         LDKUnsignedNodeAnnouncement this_ptr_conv;
19180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19181         this_ptr_conv.is_owned = false;
19182         LDKNodeFeatures val_conv;
19183         val_conv.inner = (void*)(val & (~1));
19184         val_conv.is_owned = (val & 1) || (val == 0);
19185         val_conv = NodeFeatures_clone(&val_conv);
19186         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
19187 }
19188
19189 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
19190         LDKUnsignedNodeAnnouncement this_ptr_conv;
19191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19192         this_ptr_conv.is_owned = false;
19193         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
19194         return ret_val;
19195 }
19196
19197 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
19198         LDKUnsignedNodeAnnouncement this_ptr_conv;
19199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19200         this_ptr_conv.is_owned = false;
19201         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
19202 }
19203
19204 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
19205         LDKUnsignedNodeAnnouncement this_ptr_conv;
19206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19207         this_ptr_conv.is_owned = false;
19208         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19209         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
19210         return ret_arr;
19211 }
19212
19213 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
19214         LDKUnsignedNodeAnnouncement this_ptr_conv;
19215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19216         this_ptr_conv.is_owned = false;
19217         LDKPublicKey val_ref;
19218         CHECK(*((uint32_t*)val) == 33);
19219         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19220         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
19221 }
19222
19223 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
19224         LDKUnsignedNodeAnnouncement this_ptr_conv;
19225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19226         this_ptr_conv.is_owned = false;
19227         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
19228         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
19229         return ret_arr;
19230 }
19231
19232 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
19233         LDKUnsignedNodeAnnouncement this_ptr_conv;
19234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19235         this_ptr_conv.is_owned = false;
19236         LDKThreeBytes val_ref;
19237         CHECK(*((uint32_t*)val) == 3);
19238         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
19239         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19240 }
19241
19242 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
19243         LDKUnsignedNodeAnnouncement this_ptr_conv;
19244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19245         this_ptr_conv.is_owned = false;
19246         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19247         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
19248         return ret_arr;
19249 }
19250
19251 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
19252         LDKUnsignedNodeAnnouncement this_ptr_conv;
19253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19254         this_ptr_conv.is_owned = false;
19255         LDKThirtyTwoBytes val_ref;
19256         CHECK(*((uint32_t*)val) == 32);
19257         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19258         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19259 }
19260
19261 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
19262         LDKUnsignedNodeAnnouncement this_ptr_conv;
19263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19264         this_ptr_conv.is_owned = false;
19265         LDKCVec_NetAddressZ val_constr;
19266         val_constr.datalen = *((uint32_t*)val);
19267         if (val_constr.datalen > 0)
19268                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19269         else
19270                 val_constr.data = NULL;
19271         uint32_t* val_vals = (uint32_t*)(val + 4);
19272         for (size_t m = 0; m < val_constr.datalen; m++) {
19273                 uint32_t val_conv_12 = val_vals[m];
19274                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19275                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19276                 val_constr.data[m] = val_conv_12_conv;
19277         }
19278         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19279 }
19280
19281 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
19282         LDKUnsignedNodeAnnouncement orig_conv;
19283         orig_conv.inner = (void*)(orig & (~1));
19284         orig_conv.is_owned = false;
19285         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19286         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19287         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19288         uint64_t ret_ref = (uint64_t)ret_var.inner;
19289         if (ret_var.is_owned) {
19290                 ret_ref |= 1;
19291         }
19292         return ret_ref;
19293 }
19294
19295 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
19296         LDKNodeAnnouncement this_obj_conv;
19297         this_obj_conv.inner = (void*)(this_obj & (~1));
19298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19299         NodeAnnouncement_free(this_obj_conv);
19300 }
19301
19302 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
19303         LDKNodeAnnouncement this_ptr_conv;
19304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19305         this_ptr_conv.is_owned = false;
19306         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19307         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
19308         return ret_arr;
19309 }
19310
19311 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
19312         LDKNodeAnnouncement this_ptr_conv;
19313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19314         this_ptr_conv.is_owned = false;
19315         LDKSignature val_ref;
19316         CHECK(*((uint32_t*)val) == 64);
19317         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19318         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19319 }
19320
19321 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
19322         LDKNodeAnnouncement this_ptr_conv;
19323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19324         this_ptr_conv.is_owned = false;
19325         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19326         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19327         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19328         uint64_t ret_ref = (uint64_t)ret_var.inner;
19329         if (ret_var.is_owned) {
19330                 ret_ref |= 1;
19331         }
19332         return ret_ref;
19333 }
19334
19335 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
19336         LDKNodeAnnouncement this_ptr_conv;
19337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19338         this_ptr_conv.is_owned = false;
19339         LDKUnsignedNodeAnnouncement val_conv;
19340         val_conv.inner = (void*)(val & (~1));
19341         val_conv.is_owned = (val & 1) || (val == 0);
19342         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19343         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19344 }
19345
19346 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
19347         LDKSignature signature_arg_ref;
19348         CHECK(*((uint32_t*)signature_arg) == 64);
19349         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19350         LDKUnsignedNodeAnnouncement contents_arg_conv;
19351         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19352         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19353         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19354         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19357         uint64_t ret_ref = (uint64_t)ret_var.inner;
19358         if (ret_var.is_owned) {
19359                 ret_ref |= 1;
19360         }
19361         return ret_ref;
19362 }
19363
19364 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
19365         LDKNodeAnnouncement orig_conv;
19366         orig_conv.inner = (void*)(orig & (~1));
19367         orig_conv.is_owned = false;
19368         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19371         uint64_t ret_ref = (uint64_t)ret_var.inner;
19372         if (ret_var.is_owned) {
19373                 ret_ref |= 1;
19374         }
19375         return ret_ref;
19376 }
19377
19378 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
19379         LDKUnsignedChannelAnnouncement this_obj_conv;
19380         this_obj_conv.inner = (void*)(this_obj & (~1));
19381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19382         UnsignedChannelAnnouncement_free(this_obj_conv);
19383 }
19384
19385 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
19386         LDKUnsignedChannelAnnouncement this_ptr_conv;
19387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19388         this_ptr_conv.is_owned = false;
19389         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19392         uint64_t ret_ref = (uint64_t)ret_var.inner;
19393         if (ret_var.is_owned) {
19394                 ret_ref |= 1;
19395         }
19396         return ret_ref;
19397 }
19398
19399 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
19400         LDKUnsignedChannelAnnouncement this_ptr_conv;
19401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19402         this_ptr_conv.is_owned = false;
19403         LDKChannelFeatures val_conv;
19404         val_conv.inner = (void*)(val & (~1));
19405         val_conv.is_owned = (val & 1) || (val == 0);
19406         val_conv = ChannelFeatures_clone(&val_conv);
19407         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19408 }
19409
19410 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
19411         LDKUnsignedChannelAnnouncement this_ptr_conv;
19412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19413         this_ptr_conv.is_owned = false;
19414         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19415         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
19416         return ret_arr;
19417 }
19418
19419 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19420         LDKUnsignedChannelAnnouncement this_ptr_conv;
19421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19422         this_ptr_conv.is_owned = false;
19423         LDKThirtyTwoBytes val_ref;
19424         CHECK(*((uint32_t*)val) == 32);
19425         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19426         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19427 }
19428
19429 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
19430         LDKUnsignedChannelAnnouncement this_ptr_conv;
19431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19432         this_ptr_conv.is_owned = false;
19433         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19434         return ret_val;
19435 }
19436
19437 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
19438         LDKUnsignedChannelAnnouncement this_ptr_conv;
19439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19440         this_ptr_conv.is_owned = false;
19441         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19442 }
19443
19444 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
19445         LDKUnsignedChannelAnnouncement this_ptr_conv;
19446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19447         this_ptr_conv.is_owned = false;
19448         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19449         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
19450         return ret_arr;
19451 }
19452
19453 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
19454         LDKUnsignedChannelAnnouncement this_ptr_conv;
19455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19456         this_ptr_conv.is_owned = false;
19457         LDKPublicKey val_ref;
19458         CHECK(*((uint32_t*)val) == 33);
19459         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19460         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19461 }
19462
19463 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
19464         LDKUnsignedChannelAnnouncement this_ptr_conv;
19465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19466         this_ptr_conv.is_owned = false;
19467         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19468         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
19469         return ret_arr;
19470 }
19471
19472 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
19473         LDKUnsignedChannelAnnouncement this_ptr_conv;
19474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19475         this_ptr_conv.is_owned = false;
19476         LDKPublicKey val_ref;
19477         CHECK(*((uint32_t*)val) == 33);
19478         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19479         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19480 }
19481
19482 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
19483         LDKUnsignedChannelAnnouncement this_ptr_conv;
19484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19485         this_ptr_conv.is_owned = false;
19486         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19487         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
19488         return ret_arr;
19489 }
19490
19491 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
19492         LDKUnsignedChannelAnnouncement this_ptr_conv;
19493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19494         this_ptr_conv.is_owned = false;
19495         LDKPublicKey val_ref;
19496         CHECK(*((uint32_t*)val) == 33);
19497         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19498         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19499 }
19500
19501 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
19502         LDKUnsignedChannelAnnouncement this_ptr_conv;
19503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19504         this_ptr_conv.is_owned = false;
19505         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19506         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
19507         return ret_arr;
19508 }
19509
19510 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
19511         LDKUnsignedChannelAnnouncement this_ptr_conv;
19512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19513         this_ptr_conv.is_owned = false;
19514         LDKPublicKey val_ref;
19515         CHECK(*((uint32_t*)val) == 33);
19516         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19517         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19518 }
19519
19520 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
19521         LDKUnsignedChannelAnnouncement orig_conv;
19522         orig_conv.inner = (void*)(orig & (~1));
19523         orig_conv.is_owned = false;
19524         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19525         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19526         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19527         uint64_t ret_ref = (uint64_t)ret_var.inner;
19528         if (ret_var.is_owned) {
19529                 ret_ref |= 1;
19530         }
19531         return ret_ref;
19532 }
19533
19534 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
19535         LDKChannelAnnouncement this_obj_conv;
19536         this_obj_conv.inner = (void*)(this_obj & (~1));
19537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19538         ChannelAnnouncement_free(this_obj_conv);
19539 }
19540
19541 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
19542         LDKChannelAnnouncement this_ptr_conv;
19543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19544         this_ptr_conv.is_owned = false;
19545         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19546         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
19547         return ret_arr;
19548 }
19549
19550 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
19551         LDKChannelAnnouncement this_ptr_conv;
19552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19553         this_ptr_conv.is_owned = false;
19554         LDKSignature val_ref;
19555         CHECK(*((uint32_t*)val) == 64);
19556         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19557         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19558 }
19559
19560 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
19561         LDKChannelAnnouncement this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19565         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
19566         return ret_arr;
19567 }
19568
19569 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
19570         LDKChannelAnnouncement this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         LDKSignature val_ref;
19574         CHECK(*((uint32_t*)val) == 64);
19575         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19576         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19577 }
19578
19579 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
19580         LDKChannelAnnouncement this_ptr_conv;
19581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19582         this_ptr_conv.is_owned = false;
19583         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19584         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
19585         return ret_arr;
19586 }
19587
19588 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
19589         LDKChannelAnnouncement this_ptr_conv;
19590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19591         this_ptr_conv.is_owned = false;
19592         LDKSignature val_ref;
19593         CHECK(*((uint32_t*)val) == 64);
19594         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19595         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19596 }
19597
19598 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
19599         LDKChannelAnnouncement this_ptr_conv;
19600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19601         this_ptr_conv.is_owned = false;
19602         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19603         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
19604         return ret_arr;
19605 }
19606
19607 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
19608         LDKChannelAnnouncement this_ptr_conv;
19609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19610         this_ptr_conv.is_owned = false;
19611         LDKSignature val_ref;
19612         CHECK(*((uint32_t*)val) == 64);
19613         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19614         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19615 }
19616
19617 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
19618         LDKChannelAnnouncement this_ptr_conv;
19619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19620         this_ptr_conv.is_owned = false;
19621         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19624         uint64_t ret_ref = (uint64_t)ret_var.inner;
19625         if (ret_var.is_owned) {
19626                 ret_ref |= 1;
19627         }
19628         return ret_ref;
19629 }
19630
19631 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
19632         LDKChannelAnnouncement this_ptr_conv;
19633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19634         this_ptr_conv.is_owned = false;
19635         LDKUnsignedChannelAnnouncement val_conv;
19636         val_conv.inner = (void*)(val & (~1));
19637         val_conv.is_owned = (val & 1) || (val == 0);
19638         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19639         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19640 }
19641
19642 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) {
19643         LDKSignature node_signature_1_arg_ref;
19644         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
19645         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
19646         LDKSignature node_signature_2_arg_ref;
19647         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
19648         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
19649         LDKSignature bitcoin_signature_1_arg_ref;
19650         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
19651         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
19652         LDKSignature bitcoin_signature_2_arg_ref;
19653         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
19654         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
19655         LDKUnsignedChannelAnnouncement contents_arg_conv;
19656         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19657         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19658         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19659         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);
19660         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19661         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19662         uint64_t ret_ref = (uint64_t)ret_var.inner;
19663         if (ret_var.is_owned) {
19664                 ret_ref |= 1;
19665         }
19666         return ret_ref;
19667 }
19668
19669 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
19670         LDKChannelAnnouncement orig_conv;
19671         orig_conv.inner = (void*)(orig & (~1));
19672         orig_conv.is_owned = false;
19673         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19674         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19675         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19676         uint64_t ret_ref = (uint64_t)ret_var.inner;
19677         if (ret_var.is_owned) {
19678                 ret_ref |= 1;
19679         }
19680         return ret_ref;
19681 }
19682
19683 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
19684         LDKUnsignedChannelUpdate this_obj_conv;
19685         this_obj_conv.inner = (void*)(this_obj & (~1));
19686         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19687         UnsignedChannelUpdate_free(this_obj_conv);
19688 }
19689
19690 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
19691         LDKUnsignedChannelUpdate this_ptr_conv;
19692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19693         this_ptr_conv.is_owned = false;
19694         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19695         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
19696         return ret_arr;
19697 }
19698
19699 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19700         LDKUnsignedChannelUpdate this_ptr_conv;
19701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19702         this_ptr_conv.is_owned = false;
19703         LDKThirtyTwoBytes val_ref;
19704         CHECK(*((uint32_t*)val) == 32);
19705         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19706         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19707 }
19708
19709 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
19710         LDKUnsignedChannelUpdate this_ptr_conv;
19711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19712         this_ptr_conv.is_owned = false;
19713         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19714         return ret_val;
19715 }
19716
19717 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
19718         LDKUnsignedChannelUpdate this_ptr_conv;
19719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19720         this_ptr_conv.is_owned = false;
19721         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19722 }
19723
19724 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
19725         LDKUnsignedChannelUpdate this_ptr_conv;
19726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19727         this_ptr_conv.is_owned = false;
19728         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19729         return ret_val;
19730 }
19731
19732 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
19733         LDKUnsignedChannelUpdate this_ptr_conv;
19734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19735         this_ptr_conv.is_owned = false;
19736         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19737 }
19738
19739 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
19740         LDKUnsignedChannelUpdate this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19744         return ret_val;
19745 }
19746
19747 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
19748         LDKUnsignedChannelUpdate this_ptr_conv;
19749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19750         this_ptr_conv.is_owned = false;
19751         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19752 }
19753
19754 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
19755         LDKUnsignedChannelUpdate this_ptr_conv;
19756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19757         this_ptr_conv.is_owned = false;
19758         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19759         return ret_val;
19760 }
19761
19762 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
19763         LDKUnsignedChannelUpdate this_ptr_conv;
19764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19765         this_ptr_conv.is_owned = false;
19766         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19767 }
19768
19769 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
19770         LDKUnsignedChannelUpdate this_ptr_conv;
19771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19772         this_ptr_conv.is_owned = false;
19773         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19774         return ret_val;
19775 }
19776
19777 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
19778         LDKUnsignedChannelUpdate this_ptr_conv;
19779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19780         this_ptr_conv.is_owned = false;
19781         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19782 }
19783
19784 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
19785         LDKUnsignedChannelUpdate this_ptr_conv;
19786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19787         this_ptr_conv.is_owned = false;
19788         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19789         return ret_val;
19790 }
19791
19792 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
19793         LDKUnsignedChannelUpdate this_ptr_conv;
19794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19795         this_ptr_conv.is_owned = false;
19796         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19797 }
19798
19799 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
19800         LDKUnsignedChannelUpdate this_ptr_conv;
19801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19802         this_ptr_conv.is_owned = false;
19803         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19804         return ret_val;
19805 }
19806
19807 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
19808         LDKUnsignedChannelUpdate this_ptr_conv;
19809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19810         this_ptr_conv.is_owned = false;
19811         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19812 }
19813
19814 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
19815         LDKUnsignedChannelUpdate orig_conv;
19816         orig_conv.inner = (void*)(orig & (~1));
19817         orig_conv.is_owned = false;
19818         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19819         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19820         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19821         uint64_t ret_ref = (uint64_t)ret_var.inner;
19822         if (ret_var.is_owned) {
19823                 ret_ref |= 1;
19824         }
19825         return ret_ref;
19826 }
19827
19828 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
19829         LDKChannelUpdate this_obj_conv;
19830         this_obj_conv.inner = (void*)(this_obj & (~1));
19831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19832         ChannelUpdate_free(this_obj_conv);
19833 }
19834
19835 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
19836         LDKChannelUpdate this_ptr_conv;
19837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19838         this_ptr_conv.is_owned = false;
19839         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19840         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
19841         return ret_arr;
19842 }
19843
19844 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
19845         LDKChannelUpdate this_ptr_conv;
19846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19847         this_ptr_conv.is_owned = false;
19848         LDKSignature val_ref;
19849         CHECK(*((uint32_t*)val) == 64);
19850         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19851         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19852 }
19853
19854 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
19855         LDKChannelUpdate this_ptr_conv;
19856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19857         this_ptr_conv.is_owned = false;
19858         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
19859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19861         uint64_t ret_ref = (uint64_t)ret_var.inner;
19862         if (ret_var.is_owned) {
19863                 ret_ref |= 1;
19864         }
19865         return ret_ref;
19866 }
19867
19868 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
19869         LDKChannelUpdate this_ptr_conv;
19870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19871         this_ptr_conv.is_owned = false;
19872         LDKUnsignedChannelUpdate val_conv;
19873         val_conv.inner = (void*)(val & (~1));
19874         val_conv.is_owned = (val & 1) || (val == 0);
19875         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19876         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19877 }
19878
19879 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
19880         LDKSignature signature_arg_ref;
19881         CHECK(*((uint32_t*)signature_arg) == 64);
19882         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19883         LDKUnsignedChannelUpdate contents_arg_conv;
19884         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19885         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19886         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19887         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19888         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19889         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19890         uint64_t ret_ref = (uint64_t)ret_var.inner;
19891         if (ret_var.is_owned) {
19892                 ret_ref |= 1;
19893         }
19894         return ret_ref;
19895 }
19896
19897 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
19898         LDKChannelUpdate orig_conv;
19899         orig_conv.inner = (void*)(orig & (~1));
19900         orig_conv.is_owned = false;
19901         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19904         uint64_t ret_ref = (uint64_t)ret_var.inner;
19905         if (ret_var.is_owned) {
19906                 ret_ref |= 1;
19907         }
19908         return ret_ref;
19909 }
19910
19911 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
19912         LDKQueryChannelRange this_obj_conv;
19913         this_obj_conv.inner = (void*)(this_obj & (~1));
19914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19915         QueryChannelRange_free(this_obj_conv);
19916 }
19917
19918 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
19919         LDKQueryChannelRange this_ptr_conv;
19920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19921         this_ptr_conv.is_owned = false;
19922         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19923         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
19924         return ret_arr;
19925 }
19926
19927 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19928         LDKQueryChannelRange this_ptr_conv;
19929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19930         this_ptr_conv.is_owned = false;
19931         LDKThirtyTwoBytes val_ref;
19932         CHECK(*((uint32_t*)val) == 32);
19933         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19934         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19935 }
19936
19937 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
19938         LDKQueryChannelRange this_ptr_conv;
19939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19940         this_ptr_conv.is_owned = false;
19941         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19942         return ret_val;
19943 }
19944
19945 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
19946         LDKQueryChannelRange this_ptr_conv;
19947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19948         this_ptr_conv.is_owned = false;
19949         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19950 }
19951
19952 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
19953         LDKQueryChannelRange this_ptr_conv;
19954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19955         this_ptr_conv.is_owned = false;
19956         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19957         return ret_val;
19958 }
19959
19960 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
19961         LDKQueryChannelRange this_ptr_conv;
19962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19963         this_ptr_conv.is_owned = false;
19964         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19965 }
19966
19967 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
19968         LDKThirtyTwoBytes chain_hash_arg_ref;
19969         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19970         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19971         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19974         uint64_t ret_ref = (uint64_t)ret_var.inner;
19975         if (ret_var.is_owned) {
19976                 ret_ref |= 1;
19977         }
19978         return ret_ref;
19979 }
19980
19981 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
19982         LDKQueryChannelRange orig_conv;
19983         orig_conv.inner = (void*)(orig & (~1));
19984         orig_conv.is_owned = false;
19985         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19986         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19987         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19988         uint64_t ret_ref = (uint64_t)ret_var.inner;
19989         if (ret_var.is_owned) {
19990                 ret_ref |= 1;
19991         }
19992         return ret_ref;
19993 }
19994
19995 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
19996         LDKReplyChannelRange this_obj_conv;
19997         this_obj_conv.inner = (void*)(this_obj & (~1));
19998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19999         ReplyChannelRange_free(this_obj_conv);
20000 }
20001
20002 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
20003         LDKReplyChannelRange this_ptr_conv;
20004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20005         this_ptr_conv.is_owned = false;
20006         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20007         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
20008         return ret_arr;
20009 }
20010
20011 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
20012         LDKReplyChannelRange this_ptr_conv;
20013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20014         this_ptr_conv.is_owned = false;
20015         LDKThirtyTwoBytes val_ref;
20016         CHECK(*((uint32_t*)val) == 32);
20017         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20018         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20019 }
20020
20021 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
20022         LDKReplyChannelRange this_ptr_conv;
20023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20024         this_ptr_conv.is_owned = false;
20025         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20026         return ret_val;
20027 }
20028
20029 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
20030         LDKReplyChannelRange this_ptr_conv;
20031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20032         this_ptr_conv.is_owned = false;
20033         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20034 }
20035
20036 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
20037         LDKReplyChannelRange this_ptr_conv;
20038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20039         this_ptr_conv.is_owned = false;
20040         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20041         return ret_val;
20042 }
20043
20044 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
20045         LDKReplyChannelRange this_ptr_conv;
20046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20047         this_ptr_conv.is_owned = false;
20048         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20049 }
20050
20051 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
20052         LDKReplyChannelRange this_ptr_conv;
20053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20054         this_ptr_conv.is_owned = false;
20055         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20056         return ret_val;
20057 }
20058
20059 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
20060         LDKReplyChannelRange this_ptr_conv;
20061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20062         this_ptr_conv.is_owned = false;
20063         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20064 }
20065
20066 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
20067         LDKReplyChannelRange this_ptr_conv;
20068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20069         this_ptr_conv.is_owned = false;
20070         LDKCVec_u64Z val_constr;
20071         val_constr.datalen = *((uint32_t*)val);
20072         if (val_constr.datalen > 0)
20073                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20074         else
20075                 val_constr.data = NULL;
20076         int64_t* val_vals = (int64_t*)(val + 4);
20077         for (size_t i = 0; i < val_constr.datalen; i++) {
20078                 int64_t val_conv_8 = val_vals[i];
20079                 val_constr.data[i] = val_conv_8;
20080         }
20081         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20082 }
20083
20084 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) {
20085         LDKThirtyTwoBytes chain_hash_arg_ref;
20086         CHECK(*((uint32_t*)chain_hash_arg) == 32);
20087         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
20088         LDKCVec_u64Z short_channel_ids_arg_constr;
20089         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
20090         if (short_channel_ids_arg_constr.datalen > 0)
20091                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20092         else
20093                 short_channel_ids_arg_constr.data = NULL;
20094         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
20095         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
20096                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
20097                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
20098         }
20099         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20102         uint64_t ret_ref = (uint64_t)ret_var.inner;
20103         if (ret_var.is_owned) {
20104                 ret_ref |= 1;
20105         }
20106         return ret_ref;
20107 }
20108
20109 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
20110         LDKReplyChannelRange orig_conv;
20111         orig_conv.inner = (void*)(orig & (~1));
20112         orig_conv.is_owned = false;
20113         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20116         uint64_t ret_ref = (uint64_t)ret_var.inner;
20117         if (ret_var.is_owned) {
20118                 ret_ref |= 1;
20119         }
20120         return ret_ref;
20121 }
20122
20123 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
20124         LDKQueryShortChannelIds this_obj_conv;
20125         this_obj_conv.inner = (void*)(this_obj & (~1));
20126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20127         QueryShortChannelIds_free(this_obj_conv);
20128 }
20129
20130 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
20131         LDKQueryShortChannelIds this_ptr_conv;
20132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20133         this_ptr_conv.is_owned = false;
20134         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20135         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
20136         return ret_arr;
20137 }
20138
20139 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
20140         LDKQueryShortChannelIds this_ptr_conv;
20141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20142         this_ptr_conv.is_owned = false;
20143         LDKThirtyTwoBytes val_ref;
20144         CHECK(*((uint32_t*)val) == 32);
20145         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20146         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
20147 }
20148
20149 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
20150         LDKQueryShortChannelIds this_ptr_conv;
20151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20152         this_ptr_conv.is_owned = false;
20153         LDKCVec_u64Z val_constr;
20154         val_constr.datalen = *((uint32_t*)val);
20155         if (val_constr.datalen > 0)
20156                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20157         else
20158                 val_constr.data = NULL;
20159         int64_t* val_vals = (int64_t*)(val + 4);
20160         for (size_t i = 0; i < val_constr.datalen; i++) {
20161                 int64_t val_conv_8 = val_vals[i];
20162                 val_constr.data[i] = val_conv_8;
20163         }
20164         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
20165 }
20166
20167 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
20168         LDKThirtyTwoBytes chain_hash_arg_ref;
20169         CHECK(*((uint32_t*)chain_hash_arg) == 32);
20170         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
20171         LDKCVec_u64Z short_channel_ids_arg_constr;
20172         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
20173         if (short_channel_ids_arg_constr.datalen > 0)
20174                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20175         else
20176                 short_channel_ids_arg_constr.data = NULL;
20177         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
20178         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
20179                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
20180                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
20181         }
20182         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
20183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20185         uint64_t ret_ref = (uint64_t)ret_var.inner;
20186         if (ret_var.is_owned) {
20187                 ret_ref |= 1;
20188         }
20189         return ret_ref;
20190 }
20191
20192 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
20193         LDKQueryShortChannelIds orig_conv;
20194         orig_conv.inner = (void*)(orig & (~1));
20195         orig_conv.is_owned = false;
20196         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
20197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20199         uint64_t ret_ref = (uint64_t)ret_var.inner;
20200         if (ret_var.is_owned) {
20201                 ret_ref |= 1;
20202         }
20203         return ret_ref;
20204 }
20205
20206 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
20207         LDKReplyShortChannelIdsEnd this_obj_conv;
20208         this_obj_conv.inner = (void*)(this_obj & (~1));
20209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20210         ReplyShortChannelIdsEnd_free(this_obj_conv);
20211 }
20212
20213 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
20214         LDKReplyShortChannelIdsEnd this_ptr_conv;
20215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20216         this_ptr_conv.is_owned = false;
20217         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20218         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
20219         return ret_arr;
20220 }
20221
20222 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
20223         LDKReplyShortChannelIdsEnd this_ptr_conv;
20224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20225         this_ptr_conv.is_owned = false;
20226         LDKThirtyTwoBytes val_ref;
20227         CHECK(*((uint32_t*)val) == 32);
20228         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20229         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
20230 }
20231
20232 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
20233         LDKReplyShortChannelIdsEnd this_ptr_conv;
20234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20235         this_ptr_conv.is_owned = false;
20236         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20237         return ret_val;
20238 }
20239
20240 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
20241         LDKReplyShortChannelIdsEnd this_ptr_conv;
20242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20243         this_ptr_conv.is_owned = false;
20244         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20245 }
20246
20247 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
20248         LDKThirtyTwoBytes chain_hash_arg_ref;
20249         CHECK(*((uint32_t*)chain_hash_arg) == 32);
20250         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
20251         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20254         uint64_t ret_ref = (uint64_t)ret_var.inner;
20255         if (ret_var.is_owned) {
20256                 ret_ref |= 1;
20257         }
20258         return ret_ref;
20259 }
20260
20261 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
20262         LDKReplyShortChannelIdsEnd orig_conv;
20263         orig_conv.inner = (void*)(orig & (~1));
20264         orig_conv.is_owned = false;
20265         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20268         uint64_t ret_ref = (uint64_t)ret_var.inner;
20269         if (ret_var.is_owned) {
20270                 ret_ref |= 1;
20271         }
20272         return ret_ref;
20273 }
20274
20275 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
20276         LDKGossipTimestampFilter this_obj_conv;
20277         this_obj_conv.inner = (void*)(this_obj & (~1));
20278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20279         GossipTimestampFilter_free(this_obj_conv);
20280 }
20281
20282 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
20283         LDKGossipTimestampFilter this_ptr_conv;
20284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20285         this_ptr_conv.is_owned = false;
20286         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20287         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
20288         return ret_arr;
20289 }
20290
20291 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
20292         LDKGossipTimestampFilter this_ptr_conv;
20293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20294         this_ptr_conv.is_owned = false;
20295         LDKThirtyTwoBytes val_ref;
20296         CHECK(*((uint32_t*)val) == 32);
20297         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20298         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20299 }
20300
20301 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
20302         LDKGossipTimestampFilter this_ptr_conv;
20303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20304         this_ptr_conv.is_owned = false;
20305         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20306         return ret_val;
20307 }
20308
20309 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
20310         LDKGossipTimestampFilter this_ptr_conv;
20311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20312         this_ptr_conv.is_owned = false;
20313         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20314 }
20315
20316 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
20317         LDKGossipTimestampFilter this_ptr_conv;
20318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20319         this_ptr_conv.is_owned = false;
20320         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20321         return ret_val;
20322 }
20323
20324 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
20325         LDKGossipTimestampFilter this_ptr_conv;
20326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20327         this_ptr_conv.is_owned = false;
20328         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20329 }
20330
20331 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
20332         LDKThirtyTwoBytes chain_hash_arg_ref;
20333         CHECK(*((uint32_t*)chain_hash_arg) == 32);
20334         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
20335         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20336         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20337         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20338         uint64_t ret_ref = (uint64_t)ret_var.inner;
20339         if (ret_var.is_owned) {
20340                 ret_ref |= 1;
20341         }
20342         return ret_ref;
20343 }
20344
20345 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
20346         LDKGossipTimestampFilter orig_conv;
20347         orig_conv.inner = (void*)(orig & (~1));
20348         orig_conv.is_owned = false;
20349         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20352         uint64_t ret_ref = (uint64_t)ret_var.inner;
20353         if (ret_var.is_owned) {
20354                 ret_ref |= 1;
20355         }
20356         return ret_ref;
20357 }
20358
20359 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
20360         if ((this_ptr & 1) != 0) return;
20361         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20362         FREE((void*)this_ptr);
20363         ErrorAction_free(this_ptr_conv);
20364 }
20365
20366 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
20367         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20368         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20369         *ret_copy = ErrorAction_clone(orig_conv);
20370         uint64_t ret_ref = (uint64_t)ret_copy;
20371         return ret_ref;
20372 }
20373
20374 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
20375         LDKErrorMessage msg_conv;
20376         msg_conv.inner = (void*)(msg & (~1));
20377         msg_conv.is_owned = (msg & 1) || (msg == 0);
20378         msg_conv = ErrorMessage_clone(&msg_conv);
20379         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20380         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
20381         uint64_t ret_ref = (uint64_t)ret_copy;
20382         return ret_ref;
20383 }
20384
20385 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
20386         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20387         *ret_copy = ErrorAction_ignore_error();
20388         uint64_t ret_ref = (uint64_t)ret_copy;
20389         return ret_ref;
20390 }
20391
20392 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
20393         LDKLevel a_conv = LDKLevel_from_js(a);
20394         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20395         *ret_copy = ErrorAction_ignore_and_log(a_conv);
20396         uint64_t ret_ref = (uint64_t)ret_copy;
20397         return ret_ref;
20398 }
20399
20400 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
20401         LDKErrorMessage msg_conv;
20402         msg_conv.inner = (void*)(msg & (~1));
20403         msg_conv.is_owned = (msg & 1) || (msg == 0);
20404         msg_conv = ErrorMessage_clone(&msg_conv);
20405         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20406         *ret_copy = ErrorAction_send_error_message(msg_conv);
20407         uint64_t ret_ref = (uint64_t)ret_copy;
20408         return ret_ref;
20409 }
20410
20411 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
20412         LDKLightningError this_obj_conv;
20413         this_obj_conv.inner = (void*)(this_obj & (~1));
20414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20415         LightningError_free(this_obj_conv);
20416 }
20417
20418 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
20419         LDKLightningError this_ptr_conv;
20420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20421         this_ptr_conv.is_owned = false;
20422         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20423         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20424         Str_free(ret_str);
20425         return ret_conv;
20426 }
20427
20428 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
20429         LDKLightningError this_ptr_conv;
20430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20431         this_ptr_conv.is_owned = false;
20432         LDKStr val_conv = str_ref_to_owned_c(val);
20433         LightningError_set_err(&this_ptr_conv, val_conv);
20434 }
20435
20436 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
20437         LDKLightningError this_ptr_conv;
20438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20439         this_ptr_conv.is_owned = false;
20440         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20441         *ret_copy = LightningError_get_action(&this_ptr_conv);
20442         uint64_t ret_ref = (uint64_t)ret_copy;
20443         return ret_ref;
20444 }
20445
20446 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
20447         LDKLightningError this_ptr_conv;
20448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20449         this_ptr_conv.is_owned = false;
20450         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20451         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
20452         LightningError_set_action(&this_ptr_conv, val_conv);
20453 }
20454
20455 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
20456         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
20457         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20458         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
20459         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20460         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20461         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20462         uint64_t ret_ref = (uint64_t)ret_var.inner;
20463         if (ret_var.is_owned) {
20464                 ret_ref |= 1;
20465         }
20466         return ret_ref;
20467 }
20468
20469 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
20470         LDKLightningError orig_conv;
20471         orig_conv.inner = (void*)(orig & (~1));
20472         orig_conv.is_owned = false;
20473         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20476         uint64_t ret_ref = (uint64_t)ret_var.inner;
20477         if (ret_var.is_owned) {
20478                 ret_ref |= 1;
20479         }
20480         return ret_ref;
20481 }
20482
20483 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
20484         LDKCommitmentUpdate this_obj_conv;
20485         this_obj_conv.inner = (void*)(this_obj & (~1));
20486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20487         CommitmentUpdate_free(this_obj_conv);
20488 }
20489
20490 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
20491         LDKCommitmentUpdate this_ptr_conv;
20492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20493         this_ptr_conv.is_owned = false;
20494         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
20495         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
20496         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
20497         for (size_t p = 0; p < ret_var.datalen; p++) {
20498                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
20499                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20500                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20501                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
20502                 if (ret_conv_15_var.is_owned) {
20503                         ret_conv_15_ref |= 1;
20504                 }
20505                 ret_arr_ptr[p] = ret_conv_15_ref;
20506         }
20507         FREE(ret_var.data);
20508         return ret_arr;
20509 }
20510
20511 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
20512         LDKCommitmentUpdate this_ptr_conv;
20513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20514         this_ptr_conv.is_owned = false;
20515         LDKCVec_UpdateAddHTLCZ val_constr;
20516         val_constr.datalen = *((uint32_t*)val);
20517         if (val_constr.datalen > 0)
20518                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20519         else
20520                 val_constr.data = NULL;
20521         uint32_t* val_vals = (uint32_t*)(val + 4);
20522         for (size_t p = 0; p < val_constr.datalen; p++) {
20523                 uint32_t val_conv_15 = val_vals[p];
20524                 LDKUpdateAddHTLC val_conv_15_conv;
20525                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20526                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20527                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20528                 val_constr.data[p] = val_conv_15_conv;
20529         }
20530         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20531 }
20532
20533 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
20534         LDKCommitmentUpdate this_ptr_conv;
20535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20536         this_ptr_conv.is_owned = false;
20537         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
20538         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
20539         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
20540         for (size_t t = 0; t < ret_var.datalen; t++) {
20541                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
20542                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20543                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20544                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
20545                 if (ret_conv_19_var.is_owned) {
20546                         ret_conv_19_ref |= 1;
20547                 }
20548                 ret_arr_ptr[t] = ret_conv_19_ref;
20549         }
20550         FREE(ret_var.data);
20551         return ret_arr;
20552 }
20553
20554 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
20555         LDKCommitmentUpdate this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         LDKCVec_UpdateFulfillHTLCZ val_constr;
20559         val_constr.datalen = *((uint32_t*)val);
20560         if (val_constr.datalen > 0)
20561                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20562         else
20563                 val_constr.data = NULL;
20564         uint32_t* val_vals = (uint32_t*)(val + 4);
20565         for (size_t t = 0; t < val_constr.datalen; t++) {
20566                 uint32_t val_conv_19 = val_vals[t];
20567                 LDKUpdateFulfillHTLC val_conv_19_conv;
20568                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20569                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20570                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20571                 val_constr.data[t] = val_conv_19_conv;
20572         }
20573         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20574 }
20575
20576 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
20577         LDKCommitmentUpdate this_ptr_conv;
20578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20579         this_ptr_conv.is_owned = false;
20580         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
20581         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
20582         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
20583         for (size_t q = 0; q < ret_var.datalen; q++) {
20584                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
20585                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20586                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20587                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
20588                 if (ret_conv_16_var.is_owned) {
20589                         ret_conv_16_ref |= 1;
20590                 }
20591                 ret_arr_ptr[q] = ret_conv_16_ref;
20592         }
20593         FREE(ret_var.data);
20594         return ret_arr;
20595 }
20596
20597 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
20598         LDKCommitmentUpdate this_ptr_conv;
20599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20600         this_ptr_conv.is_owned = false;
20601         LDKCVec_UpdateFailHTLCZ val_constr;
20602         val_constr.datalen = *((uint32_t*)val);
20603         if (val_constr.datalen > 0)
20604                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20605         else
20606                 val_constr.data = NULL;
20607         uint32_t* val_vals = (uint32_t*)(val + 4);
20608         for (size_t q = 0; q < val_constr.datalen; q++) {
20609                 uint32_t val_conv_16 = val_vals[q];
20610                 LDKUpdateFailHTLC val_conv_16_conv;
20611                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20612                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20613                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20614                 val_constr.data[q] = val_conv_16_conv;
20615         }
20616         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20617 }
20618
20619 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
20620         LDKCommitmentUpdate this_ptr_conv;
20621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20622         this_ptr_conv.is_owned = false;
20623         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
20624         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
20625         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
20626         for (size_t z = 0; z < ret_var.datalen; z++) {
20627                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
20628                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20629                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20630                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
20631                 if (ret_conv_25_var.is_owned) {
20632                         ret_conv_25_ref |= 1;
20633                 }
20634                 ret_arr_ptr[z] = ret_conv_25_ref;
20635         }
20636         FREE(ret_var.data);
20637         return ret_arr;
20638 }
20639
20640 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
20641         LDKCommitmentUpdate this_ptr_conv;
20642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20643         this_ptr_conv.is_owned = false;
20644         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20645         val_constr.datalen = *((uint32_t*)val);
20646         if (val_constr.datalen > 0)
20647                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20648         else
20649                 val_constr.data = NULL;
20650         uint32_t* val_vals = (uint32_t*)(val + 4);
20651         for (size_t z = 0; z < val_constr.datalen; z++) {
20652                 uint32_t val_conv_25 = val_vals[z];
20653                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20654                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20655                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20656                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20657                 val_constr.data[z] = val_conv_25_conv;
20658         }
20659         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20660 }
20661
20662 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
20663         LDKCommitmentUpdate this_ptr_conv;
20664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20665         this_ptr_conv.is_owned = false;
20666         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20669         uint64_t ret_ref = (uint64_t)ret_var.inner;
20670         if (ret_var.is_owned) {
20671                 ret_ref |= 1;
20672         }
20673         return ret_ref;
20674 }
20675
20676 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
20677         LDKCommitmentUpdate this_ptr_conv;
20678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20679         this_ptr_conv.is_owned = false;
20680         LDKUpdateFee val_conv;
20681         val_conv.inner = (void*)(val & (~1));
20682         val_conv.is_owned = (val & 1) || (val == 0);
20683         val_conv = UpdateFee_clone(&val_conv);
20684         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20685 }
20686
20687 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
20688         LDKCommitmentUpdate this_ptr_conv;
20689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20690         this_ptr_conv.is_owned = false;
20691         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20694         uint64_t ret_ref = (uint64_t)ret_var.inner;
20695         if (ret_var.is_owned) {
20696                 ret_ref |= 1;
20697         }
20698         return ret_ref;
20699 }
20700
20701 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
20702         LDKCommitmentUpdate this_ptr_conv;
20703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20704         this_ptr_conv.is_owned = false;
20705         LDKCommitmentSigned val_conv;
20706         val_conv.inner = (void*)(val & (~1));
20707         val_conv.is_owned = (val & 1) || (val == 0);
20708         val_conv = CommitmentSigned_clone(&val_conv);
20709         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20710 }
20711
20712 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) {
20713         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20714         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
20715         if (update_add_htlcs_arg_constr.datalen > 0)
20716                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20717         else
20718                 update_add_htlcs_arg_constr.data = NULL;
20719         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
20720         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20721                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20722                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20723                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20724                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20725                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20726                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20727         }
20728         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20729         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
20730         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20731                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20732         else
20733                 update_fulfill_htlcs_arg_constr.data = NULL;
20734         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
20735         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20736                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20737                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20738                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20739                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20740                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20741                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20742         }
20743         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20744         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
20745         if (update_fail_htlcs_arg_constr.datalen > 0)
20746                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20747         else
20748                 update_fail_htlcs_arg_constr.data = NULL;
20749         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
20750         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20751                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20752                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20753                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20754                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20755                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20756                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20757         }
20758         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20759         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
20760         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20761                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20762         else
20763                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20764         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
20765         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20766                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20767                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20768                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20769                 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);
20770                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20771                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20772         }
20773         LDKUpdateFee update_fee_arg_conv;
20774         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20775         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20776         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20777         LDKCommitmentSigned commitment_signed_arg_conv;
20778         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20779         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20780         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20781         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);
20782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20784         uint64_t ret_ref = (uint64_t)ret_var.inner;
20785         if (ret_var.is_owned) {
20786                 ret_ref |= 1;
20787         }
20788         return ret_ref;
20789 }
20790
20791 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
20792         LDKCommitmentUpdate orig_conv;
20793         orig_conv.inner = (void*)(orig & (~1));
20794         orig_conv.is_owned = false;
20795         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20798         uint64_t ret_ref = (uint64_t)ret_var.inner;
20799         if (ret_var.is_owned) {
20800                 ret_ref |= 1;
20801         }
20802         return ret_ref;
20803 }
20804
20805 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
20806         if ((this_ptr & 1) != 0) return;
20807         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20808         FREE((void*)this_ptr);
20809         ChannelMessageHandler_free(this_ptr_conv);
20810 }
20811
20812 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
20813         if ((this_ptr & 1) != 0) return;
20814         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20815         FREE((void*)this_ptr);
20816         RoutingMessageHandler_free(this_ptr_conv);
20817 }
20818
20819 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
20820         LDKAcceptChannel obj_conv;
20821         obj_conv.inner = (void*)(obj & (~1));
20822         obj_conv.is_owned = false;
20823         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20824         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20825         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20826         CVec_u8Z_free(ret_var);
20827         return ret_arr;
20828 }
20829
20830 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
20831         LDKu8slice ser_ref;
20832         ser_ref.datalen = *((uint32_t*)ser);
20833         ser_ref.data = (int8_t*)(ser + 4);
20834         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20835         *ret_conv = AcceptChannel_read(ser_ref);
20836         return (uint64_t)ret_conv;
20837 }
20838
20839 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
20840         LDKAnnouncementSignatures obj_conv;
20841         obj_conv.inner = (void*)(obj & (~1));
20842         obj_conv.is_owned = false;
20843         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20844         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20845         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20846         CVec_u8Z_free(ret_var);
20847         return ret_arr;
20848 }
20849
20850 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
20851         LDKu8slice ser_ref;
20852         ser_ref.datalen = *((uint32_t*)ser);
20853         ser_ref.data = (int8_t*)(ser + 4);
20854         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20855         *ret_conv = AnnouncementSignatures_read(ser_ref);
20856         return (uint64_t)ret_conv;
20857 }
20858
20859 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
20860         LDKChannelReestablish obj_conv;
20861         obj_conv.inner = (void*)(obj & (~1));
20862         obj_conv.is_owned = false;
20863         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20864         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20865         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20866         CVec_u8Z_free(ret_var);
20867         return ret_arr;
20868 }
20869
20870 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
20871         LDKu8slice ser_ref;
20872         ser_ref.datalen = *((uint32_t*)ser);
20873         ser_ref.data = (int8_t*)(ser + 4);
20874         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20875         *ret_conv = ChannelReestablish_read(ser_ref);
20876         return (uint64_t)ret_conv;
20877 }
20878
20879 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
20880         LDKClosingSigned obj_conv;
20881         obj_conv.inner = (void*)(obj & (~1));
20882         obj_conv.is_owned = false;
20883         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20884         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20885         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20886         CVec_u8Z_free(ret_var);
20887         return ret_arr;
20888 }
20889
20890 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
20891         LDKu8slice ser_ref;
20892         ser_ref.datalen = *((uint32_t*)ser);
20893         ser_ref.data = (int8_t*)(ser + 4);
20894         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20895         *ret_conv = ClosingSigned_read(ser_ref);
20896         return (uint64_t)ret_conv;
20897 }
20898
20899 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
20900         LDKClosingSignedFeeRange obj_conv;
20901         obj_conv.inner = (void*)(obj & (~1));
20902         obj_conv.is_owned = false;
20903         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
20904         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20905         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20906         CVec_u8Z_free(ret_var);
20907         return ret_arr;
20908 }
20909
20910 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
20911         LDKu8slice ser_ref;
20912         ser_ref.datalen = *((uint32_t*)ser);
20913         ser_ref.data = (int8_t*)(ser + 4);
20914         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20915         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
20916         return (uint64_t)ret_conv;
20917 }
20918
20919 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
20920         LDKCommitmentSigned obj_conv;
20921         obj_conv.inner = (void*)(obj & (~1));
20922         obj_conv.is_owned = false;
20923         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20924         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20925         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20926         CVec_u8Z_free(ret_var);
20927         return ret_arr;
20928 }
20929
20930 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
20931         LDKu8slice ser_ref;
20932         ser_ref.datalen = *((uint32_t*)ser);
20933         ser_ref.data = (int8_t*)(ser + 4);
20934         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20935         *ret_conv = CommitmentSigned_read(ser_ref);
20936         return (uint64_t)ret_conv;
20937 }
20938
20939 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
20940         LDKFundingCreated obj_conv;
20941         obj_conv.inner = (void*)(obj & (~1));
20942         obj_conv.is_owned = false;
20943         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20944         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20945         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20946         CVec_u8Z_free(ret_var);
20947         return ret_arr;
20948 }
20949
20950 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
20951         LDKu8slice ser_ref;
20952         ser_ref.datalen = *((uint32_t*)ser);
20953         ser_ref.data = (int8_t*)(ser + 4);
20954         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20955         *ret_conv = FundingCreated_read(ser_ref);
20956         return (uint64_t)ret_conv;
20957 }
20958
20959 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
20960         LDKFundingSigned obj_conv;
20961         obj_conv.inner = (void*)(obj & (~1));
20962         obj_conv.is_owned = false;
20963         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20964         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20965         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20966         CVec_u8Z_free(ret_var);
20967         return ret_arr;
20968 }
20969
20970 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
20971         LDKu8slice ser_ref;
20972         ser_ref.datalen = *((uint32_t*)ser);
20973         ser_ref.data = (int8_t*)(ser + 4);
20974         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20975         *ret_conv = FundingSigned_read(ser_ref);
20976         return (uint64_t)ret_conv;
20977 }
20978
20979 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
20980         LDKFundingLocked obj_conv;
20981         obj_conv.inner = (void*)(obj & (~1));
20982         obj_conv.is_owned = false;
20983         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20984         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20985         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20986         CVec_u8Z_free(ret_var);
20987         return ret_arr;
20988 }
20989
20990 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
20991         LDKu8slice ser_ref;
20992         ser_ref.datalen = *((uint32_t*)ser);
20993         ser_ref.data = (int8_t*)(ser + 4);
20994         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20995         *ret_conv = FundingLocked_read(ser_ref);
20996         return (uint64_t)ret_conv;
20997 }
20998
20999 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
21000         LDKInit obj_conv;
21001         obj_conv.inner = (void*)(obj & (~1));
21002         obj_conv.is_owned = false;
21003         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
21004         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21005         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21006         CVec_u8Z_free(ret_var);
21007         return ret_arr;
21008 }
21009
21010 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
21011         LDKu8slice ser_ref;
21012         ser_ref.datalen = *((uint32_t*)ser);
21013         ser_ref.data = (int8_t*)(ser + 4);
21014         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21015         *ret_conv = Init_read(ser_ref);
21016         return (uint64_t)ret_conv;
21017 }
21018
21019 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
21020         LDKOpenChannel obj_conv;
21021         obj_conv.inner = (void*)(obj & (~1));
21022         obj_conv.is_owned = false;
21023         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
21024         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21025         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21026         CVec_u8Z_free(ret_var);
21027         return ret_arr;
21028 }
21029
21030 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
21031         LDKu8slice ser_ref;
21032         ser_ref.datalen = *((uint32_t*)ser);
21033         ser_ref.data = (int8_t*)(ser + 4);
21034         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21035         *ret_conv = OpenChannel_read(ser_ref);
21036         return (uint64_t)ret_conv;
21037 }
21038
21039 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
21040         LDKRevokeAndACK obj_conv;
21041         obj_conv.inner = (void*)(obj & (~1));
21042         obj_conv.is_owned = false;
21043         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
21044         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21045         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21046         CVec_u8Z_free(ret_var);
21047         return ret_arr;
21048 }
21049
21050 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
21051         LDKu8slice ser_ref;
21052         ser_ref.datalen = *((uint32_t*)ser);
21053         ser_ref.data = (int8_t*)(ser + 4);
21054         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21055         *ret_conv = RevokeAndACK_read(ser_ref);
21056         return (uint64_t)ret_conv;
21057 }
21058
21059 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
21060         LDKShutdown obj_conv;
21061         obj_conv.inner = (void*)(obj & (~1));
21062         obj_conv.is_owned = false;
21063         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
21064         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21065         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21066         CVec_u8Z_free(ret_var);
21067         return ret_arr;
21068 }
21069
21070 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
21071         LDKu8slice ser_ref;
21072         ser_ref.datalen = *((uint32_t*)ser);
21073         ser_ref.data = (int8_t*)(ser + 4);
21074         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21075         *ret_conv = Shutdown_read(ser_ref);
21076         return (uint64_t)ret_conv;
21077 }
21078
21079 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
21080         LDKUpdateFailHTLC obj_conv;
21081         obj_conv.inner = (void*)(obj & (~1));
21082         obj_conv.is_owned = false;
21083         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
21084         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21085         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21086         CVec_u8Z_free(ret_var);
21087         return ret_arr;
21088 }
21089
21090 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
21091         LDKu8slice ser_ref;
21092         ser_ref.datalen = *((uint32_t*)ser);
21093         ser_ref.data = (int8_t*)(ser + 4);
21094         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21095         *ret_conv = UpdateFailHTLC_read(ser_ref);
21096         return (uint64_t)ret_conv;
21097 }
21098
21099 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
21100         LDKUpdateFailMalformedHTLC obj_conv;
21101         obj_conv.inner = (void*)(obj & (~1));
21102         obj_conv.is_owned = false;
21103         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
21104         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21105         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21106         CVec_u8Z_free(ret_var);
21107         return ret_arr;
21108 }
21109
21110 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
21111         LDKu8slice ser_ref;
21112         ser_ref.datalen = *((uint32_t*)ser);
21113         ser_ref.data = (int8_t*)(ser + 4);
21114         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21115         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21116         return (uint64_t)ret_conv;
21117 }
21118
21119 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
21120         LDKUpdateFee obj_conv;
21121         obj_conv.inner = (void*)(obj & (~1));
21122         obj_conv.is_owned = false;
21123         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21124         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21125         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21126         CVec_u8Z_free(ret_var);
21127         return ret_arr;
21128 }
21129
21130 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
21131         LDKu8slice ser_ref;
21132         ser_ref.datalen = *((uint32_t*)ser);
21133         ser_ref.data = (int8_t*)(ser + 4);
21134         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21135         *ret_conv = UpdateFee_read(ser_ref);
21136         return (uint64_t)ret_conv;
21137 }
21138
21139 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
21140         LDKUpdateFulfillHTLC obj_conv;
21141         obj_conv.inner = (void*)(obj & (~1));
21142         obj_conv.is_owned = false;
21143         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21144         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21145         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21146         CVec_u8Z_free(ret_var);
21147         return ret_arr;
21148 }
21149
21150 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
21151         LDKu8slice ser_ref;
21152         ser_ref.datalen = *((uint32_t*)ser);
21153         ser_ref.data = (int8_t*)(ser + 4);
21154         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21155         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
21156         return (uint64_t)ret_conv;
21157 }
21158
21159 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
21160         LDKUpdateAddHTLC obj_conv;
21161         obj_conv.inner = (void*)(obj & (~1));
21162         obj_conv.is_owned = false;
21163         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
21164         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21165         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21166         CVec_u8Z_free(ret_var);
21167         return ret_arr;
21168 }
21169
21170 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
21171         LDKu8slice ser_ref;
21172         ser_ref.datalen = *((uint32_t*)ser);
21173         ser_ref.data = (int8_t*)(ser + 4);
21174         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21175         *ret_conv = UpdateAddHTLC_read(ser_ref);
21176         return (uint64_t)ret_conv;
21177 }
21178
21179 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
21180         LDKPing obj_conv;
21181         obj_conv.inner = (void*)(obj & (~1));
21182         obj_conv.is_owned = false;
21183         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
21184         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21185         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21186         CVec_u8Z_free(ret_var);
21187         return ret_arr;
21188 }
21189
21190 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
21191         LDKu8slice ser_ref;
21192         ser_ref.datalen = *((uint32_t*)ser);
21193         ser_ref.data = (int8_t*)(ser + 4);
21194         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21195         *ret_conv = Ping_read(ser_ref);
21196         return (uint64_t)ret_conv;
21197 }
21198
21199 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
21200         LDKPong obj_conv;
21201         obj_conv.inner = (void*)(obj & (~1));
21202         obj_conv.is_owned = false;
21203         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
21204         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21205         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21206         CVec_u8Z_free(ret_var);
21207         return ret_arr;
21208 }
21209
21210 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
21211         LDKu8slice ser_ref;
21212         ser_ref.datalen = *((uint32_t*)ser);
21213         ser_ref.data = (int8_t*)(ser + 4);
21214         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21215         *ret_conv = Pong_read(ser_ref);
21216         return (uint64_t)ret_conv;
21217 }
21218
21219 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
21220         LDKUnsignedChannelAnnouncement obj_conv;
21221         obj_conv.inner = (void*)(obj & (~1));
21222         obj_conv.is_owned = false;
21223         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
21224         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21225         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21226         CVec_u8Z_free(ret_var);
21227         return ret_arr;
21228 }
21229
21230 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
21231         LDKu8slice ser_ref;
21232         ser_ref.datalen = *((uint32_t*)ser);
21233         ser_ref.data = (int8_t*)(ser + 4);
21234         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21235         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
21236         return (uint64_t)ret_conv;
21237 }
21238
21239 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
21240         LDKChannelAnnouncement obj_conv;
21241         obj_conv.inner = (void*)(obj & (~1));
21242         obj_conv.is_owned = false;
21243         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
21244         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21245         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21246         CVec_u8Z_free(ret_var);
21247         return ret_arr;
21248 }
21249
21250 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
21251         LDKu8slice ser_ref;
21252         ser_ref.datalen = *((uint32_t*)ser);
21253         ser_ref.data = (int8_t*)(ser + 4);
21254         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21255         *ret_conv = ChannelAnnouncement_read(ser_ref);
21256         return (uint64_t)ret_conv;
21257 }
21258
21259 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
21260         LDKUnsignedChannelUpdate obj_conv;
21261         obj_conv.inner = (void*)(obj & (~1));
21262         obj_conv.is_owned = false;
21263         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
21264         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21265         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21266         CVec_u8Z_free(ret_var);
21267         return ret_arr;
21268 }
21269
21270 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
21271         LDKu8slice ser_ref;
21272         ser_ref.datalen = *((uint32_t*)ser);
21273         ser_ref.data = (int8_t*)(ser + 4);
21274         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21275         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
21276         return (uint64_t)ret_conv;
21277 }
21278
21279 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
21280         LDKChannelUpdate obj_conv;
21281         obj_conv.inner = (void*)(obj & (~1));
21282         obj_conv.is_owned = false;
21283         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
21284         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21285         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21286         CVec_u8Z_free(ret_var);
21287         return ret_arr;
21288 }
21289
21290 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
21291         LDKu8slice ser_ref;
21292         ser_ref.datalen = *((uint32_t*)ser);
21293         ser_ref.data = (int8_t*)(ser + 4);
21294         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21295         *ret_conv = ChannelUpdate_read(ser_ref);
21296         return (uint64_t)ret_conv;
21297 }
21298
21299 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
21300         LDKErrorMessage obj_conv;
21301         obj_conv.inner = (void*)(obj & (~1));
21302         obj_conv.is_owned = false;
21303         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
21304         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21305         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21306         CVec_u8Z_free(ret_var);
21307         return ret_arr;
21308 }
21309
21310 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
21311         LDKu8slice ser_ref;
21312         ser_ref.datalen = *((uint32_t*)ser);
21313         ser_ref.data = (int8_t*)(ser + 4);
21314         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21315         *ret_conv = ErrorMessage_read(ser_ref);
21316         return (uint64_t)ret_conv;
21317 }
21318
21319 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
21320         LDKUnsignedNodeAnnouncement obj_conv;
21321         obj_conv.inner = (void*)(obj & (~1));
21322         obj_conv.is_owned = false;
21323         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
21324         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21325         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21326         CVec_u8Z_free(ret_var);
21327         return ret_arr;
21328 }
21329
21330 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
21331         LDKu8slice ser_ref;
21332         ser_ref.datalen = *((uint32_t*)ser);
21333         ser_ref.data = (int8_t*)(ser + 4);
21334         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21335         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21336         return (uint64_t)ret_conv;
21337 }
21338
21339 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
21340         LDKNodeAnnouncement obj_conv;
21341         obj_conv.inner = (void*)(obj & (~1));
21342         obj_conv.is_owned = false;
21343         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21344         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21345         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21346         CVec_u8Z_free(ret_var);
21347         return ret_arr;
21348 }
21349
21350 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
21351         LDKu8slice ser_ref;
21352         ser_ref.datalen = *((uint32_t*)ser);
21353         ser_ref.data = (int8_t*)(ser + 4);
21354         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21355         *ret_conv = NodeAnnouncement_read(ser_ref);
21356         return (uint64_t)ret_conv;
21357 }
21358
21359 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
21360         LDKu8slice ser_ref;
21361         ser_ref.datalen = *((uint32_t*)ser);
21362         ser_ref.data = (int8_t*)(ser + 4);
21363         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21364         *ret_conv = QueryShortChannelIds_read(ser_ref);
21365         return (uint64_t)ret_conv;
21366 }
21367
21368 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
21369         LDKQueryShortChannelIds obj_conv;
21370         obj_conv.inner = (void*)(obj & (~1));
21371         obj_conv.is_owned = false;
21372         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21373         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21374         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21375         CVec_u8Z_free(ret_var);
21376         return ret_arr;
21377 }
21378
21379 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
21380         LDKReplyShortChannelIdsEnd obj_conv;
21381         obj_conv.inner = (void*)(obj & (~1));
21382         obj_conv.is_owned = false;
21383         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21384         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21385         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21386         CVec_u8Z_free(ret_var);
21387         return ret_arr;
21388 }
21389
21390 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
21391         LDKu8slice ser_ref;
21392         ser_ref.datalen = *((uint32_t*)ser);
21393         ser_ref.data = (int8_t*)(ser + 4);
21394         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21395         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21396         return (uint64_t)ret_conv;
21397 }
21398
21399 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
21400         LDKQueryChannelRange this_arg_conv;
21401         this_arg_conv.inner = (void*)(this_arg & (~1));
21402         this_arg_conv.is_owned = false;
21403         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21404         return ret_val;
21405 }
21406
21407 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
21408         LDKQueryChannelRange obj_conv;
21409         obj_conv.inner = (void*)(obj & (~1));
21410         obj_conv.is_owned = false;
21411         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21412         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21413         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21414         CVec_u8Z_free(ret_var);
21415         return ret_arr;
21416 }
21417
21418 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
21419         LDKu8slice ser_ref;
21420         ser_ref.datalen = *((uint32_t*)ser);
21421         ser_ref.data = (int8_t*)(ser + 4);
21422         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21423         *ret_conv = QueryChannelRange_read(ser_ref);
21424         return (uint64_t)ret_conv;
21425 }
21426
21427 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
21428         LDKu8slice ser_ref;
21429         ser_ref.datalen = *((uint32_t*)ser);
21430         ser_ref.data = (int8_t*)(ser + 4);
21431         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21432         *ret_conv = ReplyChannelRange_read(ser_ref);
21433         return (uint64_t)ret_conv;
21434 }
21435
21436 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
21437         LDKReplyChannelRange obj_conv;
21438         obj_conv.inner = (void*)(obj & (~1));
21439         obj_conv.is_owned = false;
21440         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21441         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21442         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21443         CVec_u8Z_free(ret_var);
21444         return ret_arr;
21445 }
21446
21447 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
21448         LDKGossipTimestampFilter obj_conv;
21449         obj_conv.inner = (void*)(obj & (~1));
21450         obj_conv.is_owned = false;
21451         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21454         CVec_u8Z_free(ret_var);
21455         return ret_arr;
21456 }
21457
21458 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
21459         LDKu8slice ser_ref;
21460         ser_ref.datalen = *((uint32_t*)ser);
21461         ser_ref.data = (int8_t*)(ser + 4);
21462         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21463         *ret_conv = GossipTimestampFilter_read(ser_ref);
21464         return (uint64_t)ret_conv;
21465 }
21466
21467 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
21468         if ((this_ptr & 1) != 0) return;
21469         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1);
21470         FREE((void*)this_ptr);
21471         CustomMessageHandler_free(this_ptr_conv);
21472 }
21473
21474 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
21475         LDKIgnoringMessageHandler this_obj_conv;
21476         this_obj_conv.inner = (void*)(this_obj & (~1));
21477         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21478         IgnoringMessageHandler_free(this_obj_conv);
21479 }
21480
21481 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
21482         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21485         uint64_t ret_ref = (uint64_t)ret_var.inner;
21486         if (ret_var.is_owned) {
21487                 ret_ref |= 1;
21488         }
21489         return ret_ref;
21490 }
21491
21492 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
21493         LDKIgnoringMessageHandler this_arg_conv;
21494         this_arg_conv.inner = (void*)(this_arg & (~1));
21495         this_arg_conv.is_owned = false;
21496         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21497         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21498         return (uint64_t)ret_ret;
21499 }
21500
21501 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
21502         LDKIgnoringMessageHandler this_arg_conv;
21503         this_arg_conv.inner = (void*)(this_arg & (~1));
21504         this_arg_conv.is_owned = false;
21505         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21506         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21507         return (uint64_t)ret_ret;
21508 }
21509
21510 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
21511         LDKIgnoringMessageHandler this_arg_conv;
21512         this_arg_conv.inner = (void*)(this_arg & (~1));
21513         this_arg_conv.is_owned = false;
21514         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
21515         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
21516         return (uint64_t)ret_ret;
21517 }
21518
21519 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
21520         LDKIgnoringMessageHandler this_arg_conv;
21521         this_arg_conv.inner = (void*)(this_arg & (~1));
21522         this_arg_conv.is_owned = false;
21523         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
21524         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
21525         return (uint64_t)ret_ret;
21526 }
21527
21528 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
21529         LDKErroringMessageHandler this_obj_conv;
21530         this_obj_conv.inner = (void*)(this_obj & (~1));
21531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21532         ErroringMessageHandler_free(this_obj_conv);
21533 }
21534
21535 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
21536         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21539         uint64_t ret_ref = (uint64_t)ret_var.inner;
21540         if (ret_var.is_owned) {
21541                 ret_ref |= 1;
21542         }
21543         return ret_ref;
21544 }
21545
21546 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
21547         LDKErroringMessageHandler this_arg_conv;
21548         this_arg_conv.inner = (void*)(this_arg & (~1));
21549         this_arg_conv.is_owned = false;
21550         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21551         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21552         return (uint64_t)ret_ret;
21553 }
21554
21555 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
21556         LDKErroringMessageHandler this_arg_conv;
21557         this_arg_conv.inner = (void*)(this_arg & (~1));
21558         this_arg_conv.is_owned = false;
21559         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21560         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21561         return (uint64_t)ret_ret;
21562 }
21563
21564 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
21565         LDKMessageHandler this_obj_conv;
21566         this_obj_conv.inner = (void*)(this_obj & (~1));
21567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21568         MessageHandler_free(this_obj_conv);
21569 }
21570
21571 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
21572         LDKMessageHandler this_ptr_conv;
21573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21574         this_ptr_conv.is_owned = false;
21575         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21576         return ret_ret;
21577 }
21578
21579 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
21580         LDKMessageHandler this_ptr_conv;
21581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21582         this_ptr_conv.is_owned = false;
21583         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21584         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21585 }
21586
21587 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
21588         LDKMessageHandler this_ptr_conv;
21589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21590         this_ptr_conv.is_owned = false;
21591         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21592         return ret_ret;
21593 }
21594
21595 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
21596         LDKMessageHandler this_ptr_conv;
21597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21598         this_ptr_conv.is_owned = false;
21599         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21600         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21601 }
21602
21603 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
21604         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21605         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21606         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21609         uint64_t ret_ref = (uint64_t)ret_var.inner;
21610         if (ret_var.is_owned) {
21611                 ret_ref |= 1;
21612         }
21613         return ret_ref;
21614 }
21615
21616 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
21617         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21618         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21619         *ret_ret = SocketDescriptor_clone(orig_conv);
21620         return (uint64_t)ret_ret;
21621 }
21622
21623 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
21624         if ((this_ptr & 1) != 0) return;
21625         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21626         FREE((void*)this_ptr);
21627         SocketDescriptor_free(this_ptr_conv);
21628 }
21629
21630 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
21631         LDKPeerHandleError this_obj_conv;
21632         this_obj_conv.inner = (void*)(this_obj & (~1));
21633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21634         PeerHandleError_free(this_obj_conv);
21635 }
21636
21637 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
21638         LDKPeerHandleError this_ptr_conv;
21639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21640         this_ptr_conv.is_owned = false;
21641         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21642         return ret_val;
21643 }
21644
21645 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
21646         LDKPeerHandleError this_ptr_conv;
21647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21648         this_ptr_conv.is_owned = false;
21649         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21650 }
21651
21652 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
21653         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21656         uint64_t ret_ref = (uint64_t)ret_var.inner;
21657         if (ret_var.is_owned) {
21658                 ret_ref |= 1;
21659         }
21660         return ret_ref;
21661 }
21662
21663 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
21664         LDKPeerHandleError orig_conv;
21665         orig_conv.inner = (void*)(orig & (~1));
21666         orig_conv.is_owned = false;
21667         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21668         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21669         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21670         uint64_t ret_ref = (uint64_t)ret_var.inner;
21671         if (ret_var.is_owned) {
21672                 ret_ref |= 1;
21673         }
21674         return ret_ref;
21675 }
21676
21677 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
21678         LDKPeerManager this_obj_conv;
21679         this_obj_conv.inner = (void*)(this_obj & (~1));
21680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21681         PeerManager_free(this_obj_conv);
21682 }
21683
21684 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) {
21685         LDKMessageHandler message_handler_conv;
21686         message_handler_conv.inner = (void*)(message_handler & (~1));
21687         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21688         // Warning: we need a move here but no clone is available for LDKMessageHandler
21689         LDKSecretKey our_node_secret_ref;
21690         CHECK(*((uint32_t*)our_node_secret) == 32);
21691         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
21692         unsigned char ephemeral_random_data_arr[32];
21693         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
21694         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
21695         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21696         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21697         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
21698         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
21699         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21700         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21701         uint64_t ret_ref = (uint64_t)ret_var.inner;
21702         if (ret_var.is_owned) {
21703                 ret_ref |= 1;
21704         }
21705         return ret_ref;
21706 }
21707
21708 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
21709         LDKPeerManager this_arg_conv;
21710         this_arg_conv.inner = (void*)(this_arg & (~1));
21711         this_arg_conv.is_owned = false;
21712         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21713         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
21714         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
21715         for (size_t m = 0; m < ret_var.datalen; m++) {
21716                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21717                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
21718                 ret_arr_ptr[m] = ret_conv_12_arr;
21719         }
21720         FREE(ret_var.data);
21721         return ret_arr;
21722 }
21723
21724 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
21725         LDKPeerManager this_arg_conv;
21726         this_arg_conv.inner = (void*)(this_arg & (~1));
21727         this_arg_conv.is_owned = false;
21728         LDKPublicKey their_node_id_ref;
21729         CHECK(*((uint32_t*)their_node_id) == 33);
21730         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
21731         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21732         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21733         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21734         return (uint64_t)ret_conv;
21735 }
21736
21737 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
21738         LDKPeerManager this_arg_conv;
21739         this_arg_conv.inner = (void*)(this_arg & (~1));
21740         this_arg_conv.is_owned = false;
21741         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21742         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21743         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21744         return (uint64_t)ret_conv;
21745 }
21746
21747 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
21748         LDKPeerManager this_arg_conv;
21749         this_arg_conv.inner = (void*)(this_arg & (~1));
21750         this_arg_conv.is_owned = false;
21751         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21752         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21753         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21754         return (uint64_t)ret_conv;
21755 }
21756
21757 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
21758         LDKPeerManager this_arg_conv;
21759         this_arg_conv.inner = (void*)(this_arg & (~1));
21760         this_arg_conv.is_owned = false;
21761         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21762         LDKu8slice data_ref;
21763         data_ref.datalen = *((uint32_t*)data);
21764         data_ref.data = (int8_t*)(data + 4);
21765         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21766         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21767         return (uint64_t)ret_conv;
21768 }
21769
21770 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
21771         LDKPeerManager this_arg_conv;
21772         this_arg_conv.inner = (void*)(this_arg & (~1));
21773         this_arg_conv.is_owned = false;
21774         PeerManager_process_events(&this_arg_conv);
21775 }
21776
21777 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
21778         LDKPeerManager this_arg_conv;
21779         this_arg_conv.inner = (void*)(this_arg & (~1));
21780         this_arg_conv.is_owned = false;
21781         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21782         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21783 }
21784
21785 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
21786         LDKPeerManager this_arg_conv;
21787         this_arg_conv.inner = (void*)(this_arg & (~1));
21788         this_arg_conv.is_owned = false;
21789         LDKPublicKey node_id_ref;
21790         CHECK(*((uint32_t*)node_id) == 33);
21791         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
21792         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21793 }
21794
21795 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
21796         LDKPeerManager this_arg_conv;
21797         this_arg_conv.inner = (void*)(this_arg & (~1));
21798         this_arg_conv.is_owned = false;
21799         PeerManager_timer_tick_occurred(&this_arg_conv);
21800 }
21801
21802 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
21803         unsigned char commitment_seed_arr[32];
21804         CHECK(*((uint32_t*)commitment_seed) == 32);
21805         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
21806         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21807         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21808         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
21809         return ret_arr;
21810 }
21811
21812 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) {
21813         LDKCVec_u8Z to_holder_script_ref;
21814         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
21815         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
21816         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
21817         LDKCVec_u8Z to_counterparty_script_ref;
21818         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
21819         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
21820         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
21821         LDKOutPoint funding_outpoint_conv;
21822         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
21823         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
21824         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
21825         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);
21826         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21827         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21828         Transaction_free(ret_var);
21829         return ret_arr;
21830 }
21831
21832 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
21833         LDKPublicKey per_commitment_point_ref;
21834         CHECK(*((uint32_t*)per_commitment_point) == 33);
21835         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21836         unsigned char base_secret_arr[32];
21837         CHECK(*((uint32_t*)base_secret) == 32);
21838         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
21839         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21840         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21841         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21842         return (uint64_t)ret_conv;
21843 }
21844
21845 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
21846         LDKPublicKey per_commitment_point_ref;
21847         CHECK(*((uint32_t*)per_commitment_point) == 33);
21848         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21849         LDKPublicKey base_point_ref;
21850         CHECK(*((uint32_t*)base_point) == 33);
21851         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
21852         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21853         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21854         return (uint64_t)ret_conv;
21855 }
21856
21857 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
21858         unsigned char per_commitment_secret_arr[32];
21859         CHECK(*((uint32_t*)per_commitment_secret) == 32);
21860         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
21861         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21862         unsigned char countersignatory_revocation_base_secret_arr[32];
21863         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
21864         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
21865         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21866         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21867         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21868         return (uint64_t)ret_conv;
21869 }
21870
21871 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
21872         LDKPublicKey per_commitment_point_ref;
21873         CHECK(*((uint32_t*)per_commitment_point) == 33);
21874         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21875         LDKPublicKey countersignatory_revocation_base_point_ref;
21876         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
21877         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
21878         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21879         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21880         return (uint64_t)ret_conv;
21881 }
21882
21883 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
21884         LDKTxCreationKeys this_obj_conv;
21885         this_obj_conv.inner = (void*)(this_obj & (~1));
21886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21887         TxCreationKeys_free(this_obj_conv);
21888 }
21889
21890 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
21891         LDKTxCreationKeys this_ptr_conv;
21892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21893         this_ptr_conv.is_owned = false;
21894         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21895         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
21896         return ret_arr;
21897 }
21898
21899 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
21900         LDKTxCreationKeys this_ptr_conv;
21901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21902         this_ptr_conv.is_owned = false;
21903         LDKPublicKey val_ref;
21904         CHECK(*((uint32_t*)val) == 33);
21905         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21906         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21907 }
21908
21909 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
21910         LDKTxCreationKeys this_ptr_conv;
21911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21912         this_ptr_conv.is_owned = false;
21913         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21914         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
21915         return ret_arr;
21916 }
21917
21918 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
21919         LDKTxCreationKeys this_ptr_conv;
21920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21921         this_ptr_conv.is_owned = false;
21922         LDKPublicKey val_ref;
21923         CHECK(*((uint32_t*)val) == 33);
21924         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21925         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21926 }
21927
21928 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
21929         LDKTxCreationKeys this_ptr_conv;
21930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21931         this_ptr_conv.is_owned = false;
21932         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21933         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
21934         return ret_arr;
21935 }
21936
21937 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
21938         LDKTxCreationKeys this_ptr_conv;
21939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21940         this_ptr_conv.is_owned = false;
21941         LDKPublicKey val_ref;
21942         CHECK(*((uint32_t*)val) == 33);
21943         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21944         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21945 }
21946
21947 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
21948         LDKTxCreationKeys this_ptr_conv;
21949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21950         this_ptr_conv.is_owned = false;
21951         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21952         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
21953         return ret_arr;
21954 }
21955
21956 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
21957         LDKTxCreationKeys this_ptr_conv;
21958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21959         this_ptr_conv.is_owned = false;
21960         LDKPublicKey val_ref;
21961         CHECK(*((uint32_t*)val) == 33);
21962         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21963         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21964 }
21965
21966 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
21967         LDKTxCreationKeys this_ptr_conv;
21968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21969         this_ptr_conv.is_owned = false;
21970         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21971         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
21972         return ret_arr;
21973 }
21974
21975 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
21976         LDKTxCreationKeys this_ptr_conv;
21977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21978         this_ptr_conv.is_owned = false;
21979         LDKPublicKey val_ref;
21980         CHECK(*((uint32_t*)val) == 33);
21981         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21982         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21983 }
21984
21985 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) {
21986         LDKPublicKey per_commitment_point_arg_ref;
21987         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
21988         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
21989         LDKPublicKey revocation_key_arg_ref;
21990         CHECK(*((uint32_t*)revocation_key_arg) == 33);
21991         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
21992         LDKPublicKey broadcaster_htlc_key_arg_ref;
21993         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
21994         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
21995         LDKPublicKey countersignatory_htlc_key_arg_ref;
21996         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
21997         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
21998         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21999         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
22000         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
22001         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);
22002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22004         uint64_t ret_ref = (uint64_t)ret_var.inner;
22005         if (ret_var.is_owned) {
22006                 ret_ref |= 1;
22007         }
22008         return ret_ref;
22009 }
22010
22011 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
22012         LDKTxCreationKeys orig_conv;
22013         orig_conv.inner = (void*)(orig & (~1));
22014         orig_conv.is_owned = false;
22015         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
22016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22018         uint64_t ret_ref = (uint64_t)ret_var.inner;
22019         if (ret_var.is_owned) {
22020                 ret_ref |= 1;
22021         }
22022         return ret_ref;
22023 }
22024
22025 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
22026         LDKTxCreationKeys obj_conv;
22027         obj_conv.inner = (void*)(obj & (~1));
22028         obj_conv.is_owned = false;
22029         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
22030         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22031         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22032         CVec_u8Z_free(ret_var);
22033         return ret_arr;
22034 }
22035
22036 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
22037         LDKu8slice ser_ref;
22038         ser_ref.datalen = *((uint32_t*)ser);
22039         ser_ref.data = (int8_t*)(ser + 4);
22040         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
22041         *ret_conv = TxCreationKeys_read(ser_ref);
22042         return (uint64_t)ret_conv;
22043 }
22044
22045 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
22046         LDKChannelPublicKeys this_obj_conv;
22047         this_obj_conv.inner = (void*)(this_obj & (~1));
22048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22049         ChannelPublicKeys_free(this_obj_conv);
22050 }
22051
22052 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
22053         LDKChannelPublicKeys this_ptr_conv;
22054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22055         this_ptr_conv.is_owned = false;
22056         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22057         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22058         return ret_arr;
22059 }
22060
22061 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22062         LDKChannelPublicKeys this_ptr_conv;
22063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22064         this_ptr_conv.is_owned = false;
22065         LDKPublicKey val_ref;
22066         CHECK(*((uint32_t*)val) == 33);
22067         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22068         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
22069 }
22070
22071 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
22072         LDKChannelPublicKeys this_ptr_conv;
22073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22074         this_ptr_conv.is_owned = false;
22075         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22076         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22077         return ret_arr;
22078 }
22079
22080 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22081         LDKChannelPublicKeys this_ptr_conv;
22082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22083         this_ptr_conv.is_owned = false;
22084         LDKPublicKey val_ref;
22085         CHECK(*((uint32_t*)val) == 33);
22086         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22087         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
22088 }
22089
22090 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
22091         LDKChannelPublicKeys this_ptr_conv;
22092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22093         this_ptr_conv.is_owned = false;
22094         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22095         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
22096         return ret_arr;
22097 }
22098
22099 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
22100         LDKChannelPublicKeys this_ptr_conv;
22101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22102         this_ptr_conv.is_owned = false;
22103         LDKPublicKey val_ref;
22104         CHECK(*((uint32_t*)val) == 33);
22105         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22106         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
22107 }
22108
22109 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
22110         LDKChannelPublicKeys this_ptr_conv;
22111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22112         this_ptr_conv.is_owned = false;
22113         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22114         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
22115         return ret_arr;
22116 }
22117
22118 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
22119         LDKChannelPublicKeys this_ptr_conv;
22120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22121         this_ptr_conv.is_owned = false;
22122         LDKPublicKey val_ref;
22123         CHECK(*((uint32_t*)val) == 33);
22124         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22125         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22126 }
22127
22128 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
22129         LDKChannelPublicKeys this_ptr_conv;
22130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22131         this_ptr_conv.is_owned = false;
22132         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22133         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
22134         return ret_arr;
22135 }
22136
22137 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
22138         LDKChannelPublicKeys this_ptr_conv;
22139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22140         this_ptr_conv.is_owned = false;
22141         LDKPublicKey val_ref;
22142         CHECK(*((uint32_t*)val) == 33);
22143         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22144         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22145 }
22146
22147 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) {
22148         LDKPublicKey funding_pubkey_arg_ref;
22149         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
22150         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
22151         LDKPublicKey revocation_basepoint_arg_ref;
22152         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
22153         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
22154         LDKPublicKey payment_point_arg_ref;
22155         CHECK(*((uint32_t*)payment_point_arg) == 33);
22156         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
22157         LDKPublicKey delayed_payment_basepoint_arg_ref;
22158         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
22159         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
22160         LDKPublicKey htlc_basepoint_arg_ref;
22161         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
22162         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
22163         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);
22164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22166         uint64_t ret_ref = (uint64_t)ret_var.inner;
22167         if (ret_var.is_owned) {
22168                 ret_ref |= 1;
22169         }
22170         return ret_ref;
22171 }
22172
22173 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
22174         LDKChannelPublicKeys orig_conv;
22175         orig_conv.inner = (void*)(orig & (~1));
22176         orig_conv.is_owned = false;
22177         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
22178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22180         uint64_t ret_ref = (uint64_t)ret_var.inner;
22181         if (ret_var.is_owned) {
22182                 ret_ref |= 1;
22183         }
22184         return ret_ref;
22185 }
22186
22187 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
22188         LDKChannelPublicKeys obj_conv;
22189         obj_conv.inner = (void*)(obj & (~1));
22190         obj_conv.is_owned = false;
22191         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
22192         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22193         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22194         CVec_u8Z_free(ret_var);
22195         return ret_arr;
22196 }
22197
22198 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
22199         LDKu8slice ser_ref;
22200         ser_ref.datalen = *((uint32_t*)ser);
22201         ser_ref.data = (int8_t*)(ser + 4);
22202         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
22203         *ret_conv = ChannelPublicKeys_read(ser_ref);
22204         return (uint64_t)ret_conv;
22205 }
22206
22207 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) {
22208         LDKPublicKey per_commitment_point_ref;
22209         CHECK(*((uint32_t*)per_commitment_point) == 33);
22210         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
22211         LDKPublicKey broadcaster_delayed_payment_base_ref;
22212         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
22213         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
22214         LDKPublicKey broadcaster_htlc_base_ref;
22215         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
22216         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
22217         LDKPublicKey countersignatory_revocation_base_ref;
22218         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
22219         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
22220         LDKPublicKey countersignatory_htlc_base_ref;
22221         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
22222         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
22223         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22224         *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);
22225         return (uint64_t)ret_conv;
22226 }
22227
22228 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
22229         LDKPublicKey per_commitment_point_ref;
22230         CHECK(*((uint32_t*)per_commitment_point) == 33);
22231         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
22232         LDKChannelPublicKeys broadcaster_keys_conv;
22233         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22234         broadcaster_keys_conv.is_owned = false;
22235         LDKChannelPublicKeys countersignatory_keys_conv;
22236         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22237         countersignatory_keys_conv.is_owned = false;
22238         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22239         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
22240         return (uint64_t)ret_conv;
22241 }
22242
22243 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
22244         LDKPublicKey revocation_key_ref;
22245         CHECK(*((uint32_t*)revocation_key) == 33);
22246         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
22247         LDKPublicKey broadcaster_delayed_payment_key_ref;
22248         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
22249         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
22250         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
22251         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22252         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22253         CVec_u8Z_free(ret_var);
22254         return ret_arr;
22255 }
22256
22257 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
22258         LDKHTLCOutputInCommitment this_obj_conv;
22259         this_obj_conv.inner = (void*)(this_obj & (~1));
22260         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22261         HTLCOutputInCommitment_free(this_obj_conv);
22262 }
22263
22264 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
22265         LDKHTLCOutputInCommitment this_ptr_conv;
22266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22267         this_ptr_conv.is_owned = false;
22268         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
22269         return ret_val;
22270 }
22271
22272 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
22273         LDKHTLCOutputInCommitment this_ptr_conv;
22274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22275         this_ptr_conv.is_owned = false;
22276         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
22277 }
22278
22279 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
22280         LDKHTLCOutputInCommitment this_ptr_conv;
22281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22282         this_ptr_conv.is_owned = false;
22283         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
22284         return ret_val;
22285 }
22286
22287 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
22288         LDKHTLCOutputInCommitment this_ptr_conv;
22289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22290         this_ptr_conv.is_owned = false;
22291         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
22292 }
22293
22294 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
22295         LDKHTLCOutputInCommitment this_ptr_conv;
22296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22297         this_ptr_conv.is_owned = false;
22298         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
22299         return ret_val;
22300 }
22301
22302 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
22303         LDKHTLCOutputInCommitment this_ptr_conv;
22304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22305         this_ptr_conv.is_owned = false;
22306         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
22307 }
22308
22309 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
22310         LDKHTLCOutputInCommitment this_ptr_conv;
22311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22312         this_ptr_conv.is_owned = false;
22313         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22314         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
22315         return ret_arr;
22316 }
22317
22318 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
22319         LDKHTLCOutputInCommitment this_ptr_conv;
22320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22321         this_ptr_conv.is_owned = false;
22322         LDKThirtyTwoBytes val_ref;
22323         CHECK(*((uint32_t*)val) == 32);
22324         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22325         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
22326 }
22327
22328 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
22329         LDKHTLCOutputInCommitment this_ptr_conv;
22330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22331         this_ptr_conv.is_owned = false;
22332         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
22333         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
22334         uint64_t ret_ref = (uint64_t)ret_copy;
22335         return ret_ref;
22336 }
22337
22338 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
22339         LDKHTLCOutputInCommitment this_ptr_conv;
22340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22341         this_ptr_conv.is_owned = false;
22342         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22343         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
22344         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22345 }
22346
22347 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) {
22348         LDKThirtyTwoBytes payment_hash_arg_ref;
22349         CHECK(*((uint32_t*)payment_hash_arg) == 32);
22350         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
22351         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22352         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
22353         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22356         uint64_t ret_ref = (uint64_t)ret_var.inner;
22357         if (ret_var.is_owned) {
22358                 ret_ref |= 1;
22359         }
22360         return ret_ref;
22361 }
22362
22363 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
22364         LDKHTLCOutputInCommitment orig_conv;
22365         orig_conv.inner = (void*)(orig & (~1));
22366         orig_conv.is_owned = false;
22367         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22370         uint64_t ret_ref = (uint64_t)ret_var.inner;
22371         if (ret_var.is_owned) {
22372                 ret_ref |= 1;
22373         }
22374         return ret_ref;
22375 }
22376
22377 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
22378         LDKHTLCOutputInCommitment obj_conv;
22379         obj_conv.inner = (void*)(obj & (~1));
22380         obj_conv.is_owned = false;
22381         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22382         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22383         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22384         CVec_u8Z_free(ret_var);
22385         return ret_arr;
22386 }
22387
22388 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
22389         LDKu8slice ser_ref;
22390         ser_ref.datalen = *((uint32_t*)ser);
22391         ser_ref.data = (int8_t*)(ser + 4);
22392         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22393         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22394         return (uint64_t)ret_conv;
22395 }
22396
22397 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
22398         LDKHTLCOutputInCommitment htlc_conv;
22399         htlc_conv.inner = (void*)(htlc & (~1));
22400         htlc_conv.is_owned = false;
22401         LDKTxCreationKeys keys_conv;
22402         keys_conv.inner = (void*)(keys & (~1));
22403         keys_conv.is_owned = false;
22404         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22405         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22406         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22407         CVec_u8Z_free(ret_var);
22408         return ret_arr;
22409 }
22410
22411 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
22412         LDKPublicKey broadcaster_ref;
22413         CHECK(*((uint32_t*)broadcaster) == 33);
22414         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
22415         LDKPublicKey countersignatory_ref;
22416         CHECK(*((uint32_t*)countersignatory) == 33);
22417         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
22418         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22419         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22420         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22421         CVec_u8Z_free(ret_var);
22422         return ret_arr;
22423 }
22424
22425 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) {
22426         unsigned char commitment_txid_arr[32];
22427         CHECK(*((uint32_t*)commitment_txid) == 32);
22428         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
22429         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22430         LDKHTLCOutputInCommitment htlc_conv;
22431         htlc_conv.inner = (void*)(htlc & (~1));
22432         htlc_conv.is_owned = false;
22433         LDKPublicKey broadcaster_delayed_payment_key_ref;
22434         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
22435         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
22436         LDKPublicKey revocation_key_ref;
22437         CHECK(*((uint32_t*)revocation_key) == 33);
22438         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
22439         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22440         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22441         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22442         Transaction_free(ret_var);
22443         return ret_arr;
22444 }
22445
22446 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
22447         LDKChannelTransactionParameters this_obj_conv;
22448         this_obj_conv.inner = (void*)(this_obj & (~1));
22449         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22450         ChannelTransactionParameters_free(this_obj_conv);
22451 }
22452
22453 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
22454         LDKChannelTransactionParameters this_ptr_conv;
22455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22456         this_ptr_conv.is_owned = false;
22457         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22460         uint64_t ret_ref = (uint64_t)ret_var.inner;
22461         if (ret_var.is_owned) {
22462                 ret_ref |= 1;
22463         }
22464         return ret_ref;
22465 }
22466
22467 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
22468         LDKChannelTransactionParameters this_ptr_conv;
22469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22470         this_ptr_conv.is_owned = false;
22471         LDKChannelPublicKeys val_conv;
22472         val_conv.inner = (void*)(val & (~1));
22473         val_conv.is_owned = (val & 1) || (val == 0);
22474         val_conv = ChannelPublicKeys_clone(&val_conv);
22475         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22476 }
22477
22478 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
22479         LDKChannelTransactionParameters this_ptr_conv;
22480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22481         this_ptr_conv.is_owned = false;
22482         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22483         return ret_val;
22484 }
22485
22486 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
22487         LDKChannelTransactionParameters this_ptr_conv;
22488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22489         this_ptr_conv.is_owned = false;
22490         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22491 }
22492
22493 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
22494         LDKChannelTransactionParameters this_ptr_conv;
22495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22496         this_ptr_conv.is_owned = false;
22497         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22498         return ret_val;
22499 }
22500
22501 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
22502         LDKChannelTransactionParameters this_ptr_conv;
22503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22504         this_ptr_conv.is_owned = false;
22505         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22506 }
22507
22508 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
22509         LDKChannelTransactionParameters this_ptr_conv;
22510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22511         this_ptr_conv.is_owned = false;
22512         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22515         uint64_t ret_ref = (uint64_t)ret_var.inner;
22516         if (ret_var.is_owned) {
22517                 ret_ref |= 1;
22518         }
22519         return ret_ref;
22520 }
22521
22522 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
22523         LDKChannelTransactionParameters this_ptr_conv;
22524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22525         this_ptr_conv.is_owned = false;
22526         LDKCounterpartyChannelTransactionParameters val_conv;
22527         val_conv.inner = (void*)(val & (~1));
22528         val_conv.is_owned = (val & 1) || (val == 0);
22529         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22530         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22531 }
22532
22533 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
22534         LDKChannelTransactionParameters this_ptr_conv;
22535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22536         this_ptr_conv.is_owned = false;
22537         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22540         uint64_t ret_ref = (uint64_t)ret_var.inner;
22541         if (ret_var.is_owned) {
22542                 ret_ref |= 1;
22543         }
22544         return ret_ref;
22545 }
22546
22547 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
22548         LDKChannelTransactionParameters this_ptr_conv;
22549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22550         this_ptr_conv.is_owned = false;
22551         LDKOutPoint val_conv;
22552         val_conv.inner = (void*)(val & (~1));
22553         val_conv.is_owned = (val & 1) || (val == 0);
22554         val_conv = OutPoint_clone(&val_conv);
22555         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22556 }
22557
22558 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) {
22559         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22560         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22561         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22562         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22563         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22564         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22565         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22566         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22567         LDKOutPoint funding_outpoint_arg_conv;
22568         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22569         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22570         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22571         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);
22572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22573         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22574         uint64_t ret_ref = (uint64_t)ret_var.inner;
22575         if (ret_var.is_owned) {
22576                 ret_ref |= 1;
22577         }
22578         return ret_ref;
22579 }
22580
22581 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
22582         LDKChannelTransactionParameters orig_conv;
22583         orig_conv.inner = (void*)(orig & (~1));
22584         orig_conv.is_owned = false;
22585         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22588         uint64_t ret_ref = (uint64_t)ret_var.inner;
22589         if (ret_var.is_owned) {
22590                 ret_ref |= 1;
22591         }
22592         return ret_ref;
22593 }
22594
22595 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
22596         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22597         this_obj_conv.inner = (void*)(this_obj & (~1));
22598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22599         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22600 }
22601
22602 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
22603         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22605         this_ptr_conv.is_owned = false;
22606         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22609         uint64_t ret_ref = (uint64_t)ret_var.inner;
22610         if (ret_var.is_owned) {
22611                 ret_ref |= 1;
22612         }
22613         return ret_ref;
22614 }
22615
22616 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
22617         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22619         this_ptr_conv.is_owned = false;
22620         LDKChannelPublicKeys val_conv;
22621         val_conv.inner = (void*)(val & (~1));
22622         val_conv.is_owned = (val & 1) || (val == 0);
22623         val_conv = ChannelPublicKeys_clone(&val_conv);
22624         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22625 }
22626
22627 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
22628         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22630         this_ptr_conv.is_owned = false;
22631         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22632         return ret_val;
22633 }
22634
22635 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
22636         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22638         this_ptr_conv.is_owned = false;
22639         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22640 }
22641
22642 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
22643         LDKChannelPublicKeys pubkeys_arg_conv;
22644         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22645         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22646         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22647         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22650         uint64_t ret_ref = (uint64_t)ret_var.inner;
22651         if (ret_var.is_owned) {
22652                 ret_ref |= 1;
22653         }
22654         return ret_ref;
22655 }
22656
22657 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
22658         LDKCounterpartyChannelTransactionParameters orig_conv;
22659         orig_conv.inner = (void*)(orig & (~1));
22660         orig_conv.is_owned = false;
22661         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22664         uint64_t ret_ref = (uint64_t)ret_var.inner;
22665         if (ret_var.is_owned) {
22666                 ret_ref |= 1;
22667         }
22668         return ret_ref;
22669 }
22670
22671 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
22672         LDKChannelTransactionParameters this_arg_conv;
22673         this_arg_conv.inner = (void*)(this_arg & (~1));
22674         this_arg_conv.is_owned = false;
22675         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22676         return ret_val;
22677 }
22678
22679 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
22680         LDKChannelTransactionParameters this_arg_conv;
22681         this_arg_conv.inner = (void*)(this_arg & (~1));
22682         this_arg_conv.is_owned = false;
22683         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22684         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22685         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22686         uint64_t ret_ref = (uint64_t)ret_var.inner;
22687         if (ret_var.is_owned) {
22688                 ret_ref |= 1;
22689         }
22690         return ret_ref;
22691 }
22692
22693 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
22694         LDKChannelTransactionParameters this_arg_conv;
22695         this_arg_conv.inner = (void*)(this_arg & (~1));
22696         this_arg_conv.is_owned = false;
22697         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22700         uint64_t ret_ref = (uint64_t)ret_var.inner;
22701         if (ret_var.is_owned) {
22702                 ret_ref |= 1;
22703         }
22704         return ret_ref;
22705 }
22706
22707 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
22708         LDKCounterpartyChannelTransactionParameters obj_conv;
22709         obj_conv.inner = (void*)(obj & (~1));
22710         obj_conv.is_owned = false;
22711         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22712         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22713         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22714         CVec_u8Z_free(ret_var);
22715         return ret_arr;
22716 }
22717
22718 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
22719         LDKu8slice ser_ref;
22720         ser_ref.datalen = *((uint32_t*)ser);
22721         ser_ref.data = (int8_t*)(ser + 4);
22722         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22723         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22724         return (uint64_t)ret_conv;
22725 }
22726
22727 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
22728         LDKChannelTransactionParameters obj_conv;
22729         obj_conv.inner = (void*)(obj & (~1));
22730         obj_conv.is_owned = false;
22731         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22732         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22733         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22734         CVec_u8Z_free(ret_var);
22735         return ret_arr;
22736 }
22737
22738 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
22739         LDKu8slice ser_ref;
22740         ser_ref.datalen = *((uint32_t*)ser);
22741         ser_ref.data = (int8_t*)(ser + 4);
22742         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22743         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22744         return (uint64_t)ret_conv;
22745 }
22746
22747 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
22748         LDKDirectedChannelTransactionParameters this_obj_conv;
22749         this_obj_conv.inner = (void*)(this_obj & (~1));
22750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22751         DirectedChannelTransactionParameters_free(this_obj_conv);
22752 }
22753
22754 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
22755         LDKDirectedChannelTransactionParameters this_arg_conv;
22756         this_arg_conv.inner = (void*)(this_arg & (~1));
22757         this_arg_conv.is_owned = false;
22758         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22761         uint64_t ret_ref = (uint64_t)ret_var.inner;
22762         if (ret_var.is_owned) {
22763                 ret_ref |= 1;
22764         }
22765         return ret_ref;
22766 }
22767
22768 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
22769         LDKDirectedChannelTransactionParameters this_arg_conv;
22770         this_arg_conv.inner = (void*)(this_arg & (~1));
22771         this_arg_conv.is_owned = false;
22772         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
22773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22775         uint64_t ret_ref = (uint64_t)ret_var.inner;
22776         if (ret_var.is_owned) {
22777                 ret_ref |= 1;
22778         }
22779         return ret_ref;
22780 }
22781
22782 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
22783         LDKDirectedChannelTransactionParameters this_arg_conv;
22784         this_arg_conv.inner = (void*)(this_arg & (~1));
22785         this_arg_conv.is_owned = false;
22786         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22787         return ret_val;
22788 }
22789
22790 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
22791         LDKDirectedChannelTransactionParameters this_arg_conv;
22792         this_arg_conv.inner = (void*)(this_arg & (~1));
22793         this_arg_conv.is_owned = false;
22794         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22795         return ret_val;
22796 }
22797
22798 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
22799         LDKDirectedChannelTransactionParameters this_arg_conv;
22800         this_arg_conv.inner = (void*)(this_arg & (~1));
22801         this_arg_conv.is_owned = false;
22802         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22803         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22804         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22805         uint64_t ret_ref = (uint64_t)ret_var.inner;
22806         if (ret_var.is_owned) {
22807                 ret_ref |= 1;
22808         }
22809         return ret_ref;
22810 }
22811
22812 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
22813         LDKHolderCommitmentTransaction this_obj_conv;
22814         this_obj_conv.inner = (void*)(this_obj & (~1));
22815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22816         HolderCommitmentTransaction_free(this_obj_conv);
22817 }
22818
22819 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
22820         LDKHolderCommitmentTransaction this_ptr_conv;
22821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22822         this_ptr_conv.is_owned = false;
22823         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22824         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
22825         return ret_arr;
22826 }
22827
22828 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
22829         LDKHolderCommitmentTransaction this_ptr_conv;
22830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22831         this_ptr_conv.is_owned = false;
22832         LDKSignature val_ref;
22833         CHECK(*((uint32_t*)val) == 64);
22834         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
22835         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22836 }
22837
22838 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
22839         LDKHolderCommitmentTransaction this_ptr_conv;
22840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22841         this_ptr_conv.is_owned = false;
22842         LDKCVec_SignatureZ val_constr;
22843         val_constr.datalen = *((uint32_t*)val);
22844         if (val_constr.datalen > 0)
22845                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22846         else
22847                 val_constr.data = NULL;
22848         int8_tArray* val_vals = (int8_tArray*)(val + 4);
22849         for (size_t m = 0; m < val_constr.datalen; m++) {
22850                 int8_tArray val_conv_12 = val_vals[m];
22851                 LDKSignature val_conv_12_ref;
22852                 CHECK(*((uint32_t*)val_conv_12) == 64);
22853                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
22854                 val_constr.data[m] = val_conv_12_ref;
22855         }
22856         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22857 }
22858
22859 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
22860         LDKHolderCommitmentTransaction orig_conv;
22861         orig_conv.inner = (void*)(orig & (~1));
22862         orig_conv.is_owned = false;
22863         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22866         uint64_t ret_ref = (uint64_t)ret_var.inner;
22867         if (ret_var.is_owned) {
22868                 ret_ref |= 1;
22869         }
22870         return ret_ref;
22871 }
22872
22873 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
22874         LDKHolderCommitmentTransaction obj_conv;
22875         obj_conv.inner = (void*)(obj & (~1));
22876         obj_conv.is_owned = false;
22877         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22878         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22879         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22880         CVec_u8Z_free(ret_var);
22881         return ret_arr;
22882 }
22883
22884 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
22885         LDKu8slice ser_ref;
22886         ser_ref.datalen = *((uint32_t*)ser);
22887         ser_ref.data = (int8_t*)(ser + 4);
22888         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22889         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22890         return (uint64_t)ret_conv;
22891 }
22892
22893 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) {
22894         LDKCommitmentTransaction commitment_tx_conv;
22895         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22896         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22897         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22898         LDKSignature counterparty_sig_ref;
22899         CHECK(*((uint32_t*)counterparty_sig) == 64);
22900         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
22901         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22902         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
22903         if (counterparty_htlc_sigs_constr.datalen > 0)
22904                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22905         else
22906                 counterparty_htlc_sigs_constr.data = NULL;
22907         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
22908         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
22909                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
22910                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
22911                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
22912                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
22913                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
22914         }
22915         LDKPublicKey holder_funding_key_ref;
22916         CHECK(*((uint32_t*)holder_funding_key) == 33);
22917         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
22918         LDKPublicKey counterparty_funding_key_ref;
22919         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
22920         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
22921         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22924         uint64_t ret_ref = (uint64_t)ret_var.inner;
22925         if (ret_var.is_owned) {
22926                 ret_ref |= 1;
22927         }
22928         return ret_ref;
22929 }
22930
22931 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
22932         LDKBuiltCommitmentTransaction this_obj_conv;
22933         this_obj_conv.inner = (void*)(this_obj & (~1));
22934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22935         BuiltCommitmentTransaction_free(this_obj_conv);
22936 }
22937
22938 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
22939         LDKBuiltCommitmentTransaction this_ptr_conv;
22940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22941         this_ptr_conv.is_owned = false;
22942         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22943         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22944         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22945         Transaction_free(ret_var);
22946         return ret_arr;
22947 }
22948
22949 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
22950         LDKBuiltCommitmentTransaction this_ptr_conv;
22951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22952         this_ptr_conv.is_owned = false;
22953         LDKTransaction val_ref;
22954         val_ref.datalen = *((uint32_t*)val);
22955         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22956         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
22957         val_ref.data_is_owned = true;
22958         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22959 }
22960
22961 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
22962         LDKBuiltCommitmentTransaction this_ptr_conv;
22963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22964         this_ptr_conv.is_owned = false;
22965         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22966         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
22967         return ret_arr;
22968 }
22969
22970 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
22971         LDKBuiltCommitmentTransaction this_ptr_conv;
22972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22973         this_ptr_conv.is_owned = false;
22974         LDKThirtyTwoBytes val_ref;
22975         CHECK(*((uint32_t*)val) == 32);
22976         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22977         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22978 }
22979
22980 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
22981         LDKTransaction transaction_arg_ref;
22982         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
22983         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22984         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
22985         transaction_arg_ref.data_is_owned = true;
22986         LDKThirtyTwoBytes txid_arg_ref;
22987         CHECK(*((uint32_t*)txid_arg) == 32);
22988         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
22989         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22992         uint64_t ret_ref = (uint64_t)ret_var.inner;
22993         if (ret_var.is_owned) {
22994                 ret_ref |= 1;
22995         }
22996         return ret_ref;
22997 }
22998
22999 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
23000         LDKBuiltCommitmentTransaction orig_conv;
23001         orig_conv.inner = (void*)(orig & (~1));
23002         orig_conv.is_owned = false;
23003         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
23004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23006         uint64_t ret_ref = (uint64_t)ret_var.inner;
23007         if (ret_var.is_owned) {
23008                 ret_ref |= 1;
23009         }
23010         return ret_ref;
23011 }
23012
23013 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
23014         LDKBuiltCommitmentTransaction obj_conv;
23015         obj_conv.inner = (void*)(obj & (~1));
23016         obj_conv.is_owned = false;
23017         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
23018         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23019         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23020         CVec_u8Z_free(ret_var);
23021         return ret_arr;
23022 }
23023
23024 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
23025         LDKu8slice ser_ref;
23026         ser_ref.datalen = *((uint32_t*)ser);
23027         ser_ref.data = (int8_t*)(ser + 4);
23028         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
23029         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
23030         return (uint64_t)ret_conv;
23031 }
23032
23033 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
23034         LDKBuiltCommitmentTransaction this_arg_conv;
23035         this_arg_conv.inner = (void*)(this_arg & (~1));
23036         this_arg_conv.is_owned = false;
23037         LDKu8slice funding_redeemscript_ref;
23038         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
23039         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
23040         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23041         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
23042         return ret_arr;
23043 }
23044
23045 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) {
23046         LDKBuiltCommitmentTransaction this_arg_conv;
23047         this_arg_conv.inner = (void*)(this_arg & (~1));
23048         this_arg_conv.is_owned = false;
23049         unsigned char funding_key_arr[32];
23050         CHECK(*((uint32_t*)funding_key) == 32);
23051         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
23052         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23053         LDKu8slice funding_redeemscript_ref;
23054         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
23055         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
23056         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23057         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
23058         return ret_arr;
23059 }
23060
23061 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
23062         LDKClosingTransaction this_obj_conv;
23063         this_obj_conv.inner = (void*)(this_obj & (~1));
23064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23065         ClosingTransaction_free(this_obj_conv);
23066 }
23067
23068 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) {
23069         LDKCVec_u8Z to_holder_script_ref;
23070         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
23071         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
23072         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
23073         LDKCVec_u8Z to_counterparty_script_ref;
23074         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
23075         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
23076         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
23077         LDKOutPoint funding_outpoint_conv;
23078         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
23079         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
23080         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
23081         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
23082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23084         uint64_t ret_ref = (uint64_t)ret_var.inner;
23085         if (ret_var.is_owned) {
23086                 ret_ref |= 1;
23087         }
23088         return ret_ref;
23089 }
23090
23091 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
23092         LDKClosingTransaction this_arg_conv;
23093         this_arg_conv.inner = (void*)(this_arg & (~1));
23094         this_arg_conv.is_owned = false;
23095         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
23096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23098         uint64_t ret_ref = (uint64_t)ret_var.inner;
23099         if (ret_var.is_owned) {
23100                 ret_ref |= 1;
23101         }
23102         return ret_ref;
23103 }
23104
23105 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
23106         LDKClosingTransaction this_arg_conv;
23107         this_arg_conv.inner = (void*)(this_arg & (~1));
23108         this_arg_conv.is_owned = false;
23109         LDKOutPoint funding_outpoint_conv;
23110         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
23111         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
23112         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
23113         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
23114         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
23115         return (uint64_t)ret_conv;
23116 }
23117
23118 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
23119         LDKClosingTransaction this_arg_conv;
23120         this_arg_conv.inner = (void*)(this_arg & (~1));
23121         this_arg_conv.is_owned = false;
23122         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
23123         return ret_val;
23124 }
23125
23126 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
23127         LDKClosingTransaction this_arg_conv;
23128         this_arg_conv.inner = (void*)(this_arg & (~1));
23129         this_arg_conv.is_owned = false;
23130         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
23131         return ret_val;
23132 }
23133
23134 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
23135         LDKClosingTransaction this_arg_conv;
23136         this_arg_conv.inner = (void*)(this_arg & (~1));
23137         this_arg_conv.is_owned = false;
23138         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
23139         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23140         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23141         return ret_arr;
23142 }
23143
23144 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
23145         LDKClosingTransaction this_arg_conv;
23146         this_arg_conv.inner = (void*)(this_arg & (~1));
23147         this_arg_conv.is_owned = false;
23148         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
23149         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23150         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23151         return ret_arr;
23152 }
23153
23154 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
23155         LDKTrustedClosingTransaction this_obj_conv;
23156         this_obj_conv.inner = (void*)(this_obj & (~1));
23157         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23158         TrustedClosingTransaction_free(this_obj_conv);
23159 }
23160
23161 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
23162         LDKTrustedClosingTransaction this_arg_conv;
23163         this_arg_conv.inner = (void*)(this_arg & (~1));
23164         this_arg_conv.is_owned = false;
23165         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
23166         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23167         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23168         Transaction_free(ret_var);
23169         return ret_arr;
23170 }
23171
23172 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
23173         LDKTrustedClosingTransaction this_arg_conv;
23174         this_arg_conv.inner = (void*)(this_arg & (~1));
23175         this_arg_conv.is_owned = false;
23176         LDKu8slice funding_redeemscript_ref;
23177         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
23178         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
23179         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23180         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
23181         return ret_arr;
23182 }
23183
23184 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) {
23185         LDKTrustedClosingTransaction this_arg_conv;
23186         this_arg_conv.inner = (void*)(this_arg & (~1));
23187         this_arg_conv.is_owned = false;
23188         unsigned char funding_key_arr[32];
23189         CHECK(*((uint32_t*)funding_key) == 32);
23190         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
23191         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23192         LDKu8slice funding_redeemscript_ref;
23193         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
23194         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
23195         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23196         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
23197         return ret_arr;
23198 }
23199
23200 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
23201         LDKCommitmentTransaction this_obj_conv;
23202         this_obj_conv.inner = (void*)(this_obj & (~1));
23203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23204         CommitmentTransaction_free(this_obj_conv);
23205 }
23206
23207 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
23208         LDKCommitmentTransaction orig_conv;
23209         orig_conv.inner = (void*)(orig & (~1));
23210         orig_conv.is_owned = false;
23211         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
23212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23214         uint64_t ret_ref = (uint64_t)ret_var.inner;
23215         if (ret_var.is_owned) {
23216                 ret_ref |= 1;
23217         }
23218         return ret_ref;
23219 }
23220
23221 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
23222         LDKCommitmentTransaction obj_conv;
23223         obj_conv.inner = (void*)(obj & (~1));
23224         obj_conv.is_owned = false;
23225         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
23226         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23227         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23228         CVec_u8Z_free(ret_var);
23229         return ret_arr;
23230 }
23231
23232 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
23233         LDKu8slice ser_ref;
23234         ser_ref.datalen = *((uint32_t*)ser);
23235         ser_ref.data = (int8_t*)(ser + 4);
23236         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
23237         *ret_conv = CommitmentTransaction_read(ser_ref);
23238         return (uint64_t)ret_conv;
23239 }
23240
23241 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
23242         LDKCommitmentTransaction this_arg_conv;
23243         this_arg_conv.inner = (void*)(this_arg & (~1));
23244         this_arg_conv.is_owned = false;
23245         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23246         return ret_val;
23247 }
23248
23249 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
23250         LDKCommitmentTransaction this_arg_conv;
23251         this_arg_conv.inner = (void*)(this_arg & (~1));
23252         this_arg_conv.is_owned = false;
23253         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23254         return ret_val;
23255 }
23256
23257 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
23258         LDKCommitmentTransaction this_arg_conv;
23259         this_arg_conv.inner = (void*)(this_arg & (~1));
23260         this_arg_conv.is_owned = false;
23261         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23262         return ret_val;
23263 }
23264
23265 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
23266         LDKCommitmentTransaction this_arg_conv;
23267         this_arg_conv.inner = (void*)(this_arg & (~1));
23268         this_arg_conv.is_owned = false;
23269         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23270         return ret_val;
23271 }
23272
23273 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
23274         LDKCommitmentTransaction this_arg_conv;
23275         this_arg_conv.inner = (void*)(this_arg & (~1));
23276         this_arg_conv.is_owned = false;
23277         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23278         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23279         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23280         uint64_t ret_ref = (uint64_t)ret_var.inner;
23281         if (ret_var.is_owned) {
23282                 ret_ref |= 1;
23283         }
23284         return ret_ref;
23285 }
23286
23287 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
23288         LDKCommitmentTransaction this_arg_conv;
23289         this_arg_conv.inner = (void*)(this_arg & (~1));
23290         this_arg_conv.is_owned = false;
23291         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23292         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23293         channel_parameters_conv.is_owned = false;
23294         LDKChannelPublicKeys broadcaster_keys_conv;
23295         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23296         broadcaster_keys_conv.is_owned = false;
23297         LDKChannelPublicKeys countersignatory_keys_conv;
23298         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23299         countersignatory_keys_conv.is_owned = false;
23300         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
23301         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
23302         return (uint64_t)ret_conv;
23303 }
23304
23305 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
23306         LDKTrustedCommitmentTransaction this_obj_conv;
23307         this_obj_conv.inner = (void*)(this_obj & (~1));
23308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23309         TrustedCommitmentTransaction_free(this_obj_conv);
23310 }
23311
23312 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
23313         LDKTrustedCommitmentTransaction this_arg_conv;
23314         this_arg_conv.inner = (void*)(this_arg & (~1));
23315         this_arg_conv.is_owned = false;
23316         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23317         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
23318         return ret_arr;
23319 }
23320
23321 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
23322         LDKTrustedCommitmentTransaction this_arg_conv;
23323         this_arg_conv.inner = (void*)(this_arg & (~1));
23324         this_arg_conv.is_owned = false;
23325         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
23326         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23327         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23328         uint64_t ret_ref = (uint64_t)ret_var.inner;
23329         if (ret_var.is_owned) {
23330                 ret_ref |= 1;
23331         }
23332         return ret_ref;
23333 }
23334
23335 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
23336         LDKTrustedCommitmentTransaction this_arg_conv;
23337         this_arg_conv.inner = (void*)(this_arg & (~1));
23338         this_arg_conv.is_owned = false;
23339         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
23340         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23341         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23342         uint64_t ret_ref = (uint64_t)ret_var.inner;
23343         if (ret_var.is_owned) {
23344                 ret_ref |= 1;
23345         }
23346         return ret_ref;
23347 }
23348
23349 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
23350         LDKTrustedCommitmentTransaction this_arg_conv;
23351         this_arg_conv.inner = (void*)(this_arg & (~1));
23352         this_arg_conv.is_owned = false;
23353         unsigned char htlc_base_key_arr[32];
23354         CHECK(*((uint32_t*)htlc_base_key) == 32);
23355         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
23356         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
23357         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23358         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23359         channel_parameters_conv.is_owned = false;
23360         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
23361         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
23362         return (uint64_t)ret_conv;
23363 }
23364
23365 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) {
23366         LDKPublicKey broadcaster_payment_basepoint_ref;
23367         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
23368         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
23369         LDKPublicKey countersignatory_payment_basepoint_ref;
23370         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
23371         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
23372         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
23373         return ret_val;
23374 }
23375
23376 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
23377         LDKInitFeatures a_conv;
23378         a_conv.inner = (void*)(a & (~1));
23379         a_conv.is_owned = false;
23380         LDKInitFeatures b_conv;
23381         b_conv.inner = (void*)(b & (~1));
23382         b_conv.is_owned = false;
23383         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
23384         return ret_val;
23385 }
23386
23387 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
23388         LDKNodeFeatures a_conv;
23389         a_conv.inner = (void*)(a & (~1));
23390         a_conv.is_owned = false;
23391         LDKNodeFeatures b_conv;
23392         b_conv.inner = (void*)(b & (~1));
23393         b_conv.is_owned = false;
23394         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
23395         return ret_val;
23396 }
23397
23398 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
23399         LDKChannelFeatures a_conv;
23400         a_conv.inner = (void*)(a & (~1));
23401         a_conv.is_owned = false;
23402         LDKChannelFeatures b_conv;
23403         b_conv.inner = (void*)(b & (~1));
23404         b_conv.is_owned = false;
23405         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
23406         return ret_val;
23407 }
23408
23409 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
23410         LDKInvoiceFeatures a_conv;
23411         a_conv.inner = (void*)(a & (~1));
23412         a_conv.is_owned = false;
23413         LDKInvoiceFeatures b_conv;
23414         b_conv.inner = (void*)(b & (~1));
23415         b_conv.is_owned = false;
23416         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
23417         return ret_val;
23418 }
23419
23420 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
23421         LDKInitFeatures orig_conv;
23422         orig_conv.inner = (void*)(orig & (~1));
23423         orig_conv.is_owned = false;
23424         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
23425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23427         uint64_t ret_ref = (uint64_t)ret_var.inner;
23428         if (ret_var.is_owned) {
23429                 ret_ref |= 1;
23430         }
23431         return ret_ref;
23432 }
23433
23434 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
23435         LDKNodeFeatures orig_conv;
23436         orig_conv.inner = (void*)(orig & (~1));
23437         orig_conv.is_owned = false;
23438         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
23439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23441         uint64_t ret_ref = (uint64_t)ret_var.inner;
23442         if (ret_var.is_owned) {
23443                 ret_ref |= 1;
23444         }
23445         return ret_ref;
23446 }
23447
23448 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
23449         LDKChannelFeatures orig_conv;
23450         orig_conv.inner = (void*)(orig & (~1));
23451         orig_conv.is_owned = false;
23452         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
23453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23455         uint64_t ret_ref = (uint64_t)ret_var.inner;
23456         if (ret_var.is_owned) {
23457                 ret_ref |= 1;
23458         }
23459         return ret_ref;
23460 }
23461
23462 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
23463         LDKInvoiceFeatures orig_conv;
23464         orig_conv.inner = (void*)(orig & (~1));
23465         orig_conv.is_owned = false;
23466         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
23467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23469         uint64_t ret_ref = (uint64_t)ret_var.inner;
23470         if (ret_var.is_owned) {
23471                 ret_ref |= 1;
23472         }
23473         return ret_ref;
23474 }
23475
23476 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
23477         LDKInitFeatures this_obj_conv;
23478         this_obj_conv.inner = (void*)(this_obj & (~1));
23479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23480         InitFeatures_free(this_obj_conv);
23481 }
23482
23483 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
23484         LDKNodeFeatures this_obj_conv;
23485         this_obj_conv.inner = (void*)(this_obj & (~1));
23486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23487         NodeFeatures_free(this_obj_conv);
23488 }
23489
23490 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
23491         LDKChannelFeatures this_obj_conv;
23492         this_obj_conv.inner = (void*)(this_obj & (~1));
23493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23494         ChannelFeatures_free(this_obj_conv);
23495 }
23496
23497 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
23498         LDKInvoiceFeatures this_obj_conv;
23499         this_obj_conv.inner = (void*)(this_obj & (~1));
23500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23501         InvoiceFeatures_free(this_obj_conv);
23502 }
23503
23504 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
23505         LDKInitFeatures ret_var = InitFeatures_empty();
23506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23508         uint64_t ret_ref = (uint64_t)ret_var.inner;
23509         if (ret_var.is_owned) {
23510                 ret_ref |= 1;
23511         }
23512         return ret_ref;
23513 }
23514
23515 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
23516         LDKInitFeatures ret_var = InitFeatures_known();
23517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23519         uint64_t ret_ref = (uint64_t)ret_var.inner;
23520         if (ret_var.is_owned) {
23521                 ret_ref |= 1;
23522         }
23523         return ret_ref;
23524 }
23525
23526 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
23527         LDKInitFeatures this_arg_conv;
23528         this_arg_conv.inner = (void*)(this_arg & (~1));
23529         this_arg_conv.is_owned = false;
23530         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
23531         return ret_val;
23532 }
23533
23534 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
23535         LDKNodeFeatures ret_var = NodeFeatures_empty();
23536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23538         uint64_t ret_ref = (uint64_t)ret_var.inner;
23539         if (ret_var.is_owned) {
23540                 ret_ref |= 1;
23541         }
23542         return ret_ref;
23543 }
23544
23545 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
23546         LDKNodeFeatures ret_var = NodeFeatures_known();
23547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23549         uint64_t ret_ref = (uint64_t)ret_var.inner;
23550         if (ret_var.is_owned) {
23551                 ret_ref |= 1;
23552         }
23553         return ret_ref;
23554 }
23555
23556 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
23557         LDKNodeFeatures this_arg_conv;
23558         this_arg_conv.inner = (void*)(this_arg & (~1));
23559         this_arg_conv.is_owned = false;
23560         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
23561         return ret_val;
23562 }
23563
23564 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
23565         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23566         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23567         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23568         uint64_t ret_ref = (uint64_t)ret_var.inner;
23569         if (ret_var.is_owned) {
23570                 ret_ref |= 1;
23571         }
23572         return ret_ref;
23573 }
23574
23575 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
23576         LDKChannelFeatures ret_var = ChannelFeatures_known();
23577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23579         uint64_t ret_ref = (uint64_t)ret_var.inner;
23580         if (ret_var.is_owned) {
23581                 ret_ref |= 1;
23582         }
23583         return ret_ref;
23584 }
23585
23586 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
23587         LDKChannelFeatures this_arg_conv;
23588         this_arg_conv.inner = (void*)(this_arg & (~1));
23589         this_arg_conv.is_owned = false;
23590         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
23591         return ret_val;
23592 }
23593
23594 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
23595         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23598         uint64_t ret_ref = (uint64_t)ret_var.inner;
23599         if (ret_var.is_owned) {
23600                 ret_ref |= 1;
23601         }
23602         return ret_ref;
23603 }
23604
23605 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
23606         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23609         uint64_t ret_ref = (uint64_t)ret_var.inner;
23610         if (ret_var.is_owned) {
23611                 ret_ref |= 1;
23612         }
23613         return ret_ref;
23614 }
23615
23616 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
23617         LDKInvoiceFeatures this_arg_conv;
23618         this_arg_conv.inner = (void*)(this_arg & (~1));
23619         this_arg_conv.is_owned = false;
23620         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
23621         return ret_val;
23622 }
23623
23624 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
23625         LDKInitFeatures this_arg_conv;
23626         this_arg_conv.inner = (void*)(this_arg & (~1));
23627         this_arg_conv.is_owned = false;
23628         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23629         return ret_val;
23630 }
23631
23632 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
23633         LDKNodeFeatures this_arg_conv;
23634         this_arg_conv.inner = (void*)(this_arg & (~1));
23635         this_arg_conv.is_owned = false;
23636         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23637         return ret_val;
23638 }
23639
23640 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
23641         LDKInvoiceFeatures this_arg_conv;
23642         this_arg_conv.inner = (void*)(this_arg & (~1));
23643         this_arg_conv.is_owned = false;
23644         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23645         return ret_val;
23646 }
23647
23648 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
23649         LDKInitFeatures obj_conv;
23650         obj_conv.inner = (void*)(obj & (~1));
23651         obj_conv.is_owned = false;
23652         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23653         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23654         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23655         CVec_u8Z_free(ret_var);
23656         return ret_arr;
23657 }
23658
23659 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
23660         LDKNodeFeatures obj_conv;
23661         obj_conv.inner = (void*)(obj & (~1));
23662         obj_conv.is_owned = false;
23663         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23664         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23665         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23666         CVec_u8Z_free(ret_var);
23667         return ret_arr;
23668 }
23669
23670 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
23671         LDKChannelFeatures obj_conv;
23672         obj_conv.inner = (void*)(obj & (~1));
23673         obj_conv.is_owned = false;
23674         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23675         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23676         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23677         CVec_u8Z_free(ret_var);
23678         return ret_arr;
23679 }
23680
23681 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
23682         LDKInvoiceFeatures obj_conv;
23683         obj_conv.inner = (void*)(obj & (~1));
23684         obj_conv.is_owned = false;
23685         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23686         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23687         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23688         CVec_u8Z_free(ret_var);
23689         return ret_arr;
23690 }
23691
23692 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
23693         LDKu8slice ser_ref;
23694         ser_ref.datalen = *((uint32_t*)ser);
23695         ser_ref.data = (int8_t*)(ser + 4);
23696         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23697         *ret_conv = InitFeatures_read(ser_ref);
23698         return (uint64_t)ret_conv;
23699 }
23700
23701 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
23702         LDKu8slice ser_ref;
23703         ser_ref.datalen = *((uint32_t*)ser);
23704         ser_ref.data = (int8_t*)(ser + 4);
23705         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23706         *ret_conv = NodeFeatures_read(ser_ref);
23707         return (uint64_t)ret_conv;
23708 }
23709
23710 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
23711         LDKu8slice ser_ref;
23712         ser_ref.datalen = *((uint32_t*)ser);
23713         ser_ref.data = (int8_t*)(ser + 4);
23714         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23715         *ret_conv = ChannelFeatures_read(ser_ref);
23716         return (uint64_t)ret_conv;
23717 }
23718
23719 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
23720         LDKu8slice ser_ref;
23721         ser_ref.datalen = *((uint32_t*)ser);
23722         ser_ref.data = (int8_t*)(ser + 4);
23723         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23724         *ret_conv = InvoiceFeatures_read(ser_ref);
23725         return (uint64_t)ret_conv;
23726 }
23727
23728 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
23729         LDKShutdownScript this_obj_conv;
23730         this_obj_conv.inner = (void*)(this_obj & (~1));
23731         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23732         ShutdownScript_free(this_obj_conv);
23733 }
23734
23735 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
23736         LDKShutdownScript orig_conv;
23737         orig_conv.inner = (void*)(orig & (~1));
23738         orig_conv.is_owned = false;
23739         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
23740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23742         uint64_t ret_ref = (uint64_t)ret_var.inner;
23743         if (ret_var.is_owned) {
23744                 ret_ref |= 1;
23745         }
23746         return ret_ref;
23747 }
23748
23749 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
23750         LDKInvalidShutdownScript this_obj_conv;
23751         this_obj_conv.inner = (void*)(this_obj & (~1));
23752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23753         InvalidShutdownScript_free(this_obj_conv);
23754 }
23755
23756 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
23757         LDKInvalidShutdownScript this_ptr_conv;
23758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23759         this_ptr_conv.is_owned = false;
23760         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
23761         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23762         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23763         return ret_arr;
23764 }
23765
23766 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
23767         LDKInvalidShutdownScript this_ptr_conv;
23768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23769         this_ptr_conv.is_owned = false;
23770         LDKCVec_u8Z val_ref;
23771         val_ref.datalen = *((uint32_t*)val);
23772         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23773         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
23774         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
23775 }
23776
23777 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
23778         LDKCVec_u8Z script_arg_ref;
23779         script_arg_ref.datalen = *((uint32_t*)script_arg);
23780         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23781         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
23782         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
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 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
23793         LDKShutdownScript obj_conv;
23794         obj_conv.inner = (void*)(obj & (~1));
23795         obj_conv.is_owned = false;
23796         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
23797         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23798         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23799         CVec_u8Z_free(ret_var);
23800         return ret_arr;
23801 }
23802
23803 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
23804         LDKu8slice ser_ref;
23805         ser_ref.datalen = *((uint32_t*)ser);
23806         ser_ref.data = (int8_t*)(ser + 4);
23807         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
23808         *ret_conv = ShutdownScript_read(ser_ref);
23809         return (uint64_t)ret_conv;
23810 }
23811
23812 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
23813         unsigned char pubkey_hash_arr[20];
23814         CHECK(*((uint32_t*)pubkey_hash) == 20);
23815         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
23816         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
23817         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
23818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23820         uint64_t ret_ref = (uint64_t)ret_var.inner;
23821         if (ret_var.is_owned) {
23822                 ret_ref |= 1;
23823         }
23824         return ret_ref;
23825 }
23826
23827 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
23828         unsigned char script_hash_arr[32];
23829         CHECK(*((uint32_t*)script_hash) == 32);
23830         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
23831         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
23832         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
23833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23835         uint64_t ret_ref = (uint64_t)ret_var.inner;
23836         if (ret_var.is_owned) {
23837                 ret_ref |= 1;
23838         }
23839         return ret_ref;
23840 }
23841
23842 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
23843         LDKu8slice program_ref;
23844         program_ref.datalen = *((uint32_t*)program);
23845         program_ref.data = (int8_t*)(program + 4);
23846         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
23847         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
23848         return (uint64_t)ret_conv;
23849 }
23850
23851 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
23852         LDKShutdownScript this_arg_conv;
23853         this_arg_conv.inner = (void*)(this_arg & (~1));
23854         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23855         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
23856         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
23857         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23858         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23859         CVec_u8Z_free(ret_var);
23860         return ret_arr;
23861 }
23862
23863 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
23864         LDKShutdownScript this_arg_conv;
23865         this_arg_conv.inner = (void*)(this_arg & (~1));
23866         this_arg_conv.is_owned = false;
23867         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23868         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
23869         return ret_arr;
23870 }
23871
23872 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
23873         LDKShutdownScript this_arg_conv;
23874         this_arg_conv.inner = (void*)(this_arg & (~1));
23875         this_arg_conv.is_owned = false;
23876         LDKInitFeatures features_conv;
23877         features_conv.inner = (void*)(features & (~1));
23878         features_conv.is_owned = false;
23879         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
23880         return ret_val;
23881 }
23882
23883 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
23884         if ((this_ptr & 1) != 0) return;
23885         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1);
23886         FREE((void*)this_ptr);
23887         CustomMessageReader_free(this_ptr_conv);
23888 }
23889
23890 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
23891         LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1);
23892         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
23893         *ret_ret = Type_clone(orig_conv);
23894         return (uint64_t)ret_ret;
23895 }
23896
23897 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
23898         if ((this_ptr & 1) != 0) return;
23899         LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1);
23900         FREE((void*)this_ptr);
23901         Type_free(this_ptr_conv);
23902 }
23903
23904 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
23905         if ((this_ptr & 1) != 0) return;
23906         LDKScore this_ptr_conv = *(LDKScore*)(((uint64_t)this_ptr) & ~1);
23907         FREE((void*)this_ptr);
23908         Score_free(this_ptr_conv);
23909 }
23910
23911 void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
23912         LDKNodeId this_obj_conv;
23913         this_obj_conv.inner = (void*)(this_obj & (~1));
23914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23915         NodeId_free(this_obj_conv);
23916 }
23917
23918 uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
23919         LDKNodeId orig_conv;
23920         orig_conv.inner = (void*)(orig & (~1));
23921         orig_conv.is_owned = false;
23922         LDKNodeId ret_var = NodeId_clone(&orig_conv);
23923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23925         uint64_t ret_ref = (uint64_t)ret_var.inner;
23926         if (ret_var.is_owned) {
23927                 ret_ref |= 1;
23928         }
23929         return ret_ref;
23930 }
23931
23932 uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
23933         LDKPublicKey pubkey_ref;
23934         CHECK(*((uint32_t*)pubkey) == 33);
23935         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
23936         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
23937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23939         uint64_t ret_ref = (uint64_t)ret_var.inner;
23940         if (ret_var.is_owned) {
23941                 ret_ref |= 1;
23942         }
23943         return ret_ref;
23944 }
23945
23946 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
23947         LDKNodeId this_arg_conv;
23948         this_arg_conv.inner = (void*)(this_arg & (~1));
23949         this_arg_conv.is_owned = false;
23950         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
23951         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23952         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23953         return ret_arr;
23954 }
23955
23956 int64_t  __attribute__((visibility("default"))) TS_NodeId_hash(uint32_t o) {
23957         LDKNodeId o_conv;
23958         o_conv.inner = (void*)(o & (~1));
23959         o_conv.is_owned = false;
23960         int64_t ret_val = NodeId_hash(&o_conv);
23961         return ret_val;
23962 }
23963
23964 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_write(uint32_t obj) {
23965         LDKNodeId obj_conv;
23966         obj_conv.inner = (void*)(obj & (~1));
23967         obj_conv.is_owned = false;
23968         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
23969         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23970         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23971         CVec_u8Z_free(ret_var);
23972         return ret_arr;
23973 }
23974
23975 uint32_t  __attribute__((visibility("default"))) TS_NodeId_read(int8_tArray ser) {
23976         LDKu8slice ser_ref;
23977         ser_ref.datalen = *((uint32_t*)ser);
23978         ser_ref.data = (int8_t*)(ser + 4);
23979         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
23980         *ret_conv = NodeId_read(ser_ref);
23981         return (uint64_t)ret_conv;
23982 }
23983
23984 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
23985         LDKNetworkGraph this_obj_conv;
23986         this_obj_conv.inner = (void*)(this_obj & (~1));
23987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23988         NetworkGraph_free(this_obj_conv);
23989 }
23990
23991 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
23992         LDKNetworkGraph orig_conv;
23993         orig_conv.inner = (void*)(orig & (~1));
23994         orig_conv.is_owned = false;
23995         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
23996         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23997         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23998         uint64_t ret_ref = (uint64_t)ret_var.inner;
23999         if (ret_var.is_owned) {
24000                 ret_ref |= 1;
24001         }
24002         return ret_ref;
24003 }
24004
24005 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
24006         LDKReadOnlyNetworkGraph this_obj_conv;
24007         this_obj_conv.inner = (void*)(this_obj & (~1));
24008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24009         ReadOnlyNetworkGraph_free(this_obj_conv);
24010 }
24011
24012 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
24013         if ((this_ptr & 1) != 0) return;
24014         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1);
24015         FREE((void*)this_ptr);
24016         NetworkUpdate_free(this_ptr_conv);
24017 }
24018
24019 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
24020         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
24021         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24022         *ret_copy = NetworkUpdate_clone(orig_conv);
24023         uint64_t ret_ref = (uint64_t)ret_copy;
24024         return ret_ref;
24025 }
24026
24027 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
24028         LDKChannelUpdate msg_conv;
24029         msg_conv.inner = (void*)(msg & (~1));
24030         msg_conv.is_owned = (msg & 1) || (msg == 0);
24031         msg_conv = ChannelUpdate_clone(&msg_conv);
24032         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24033         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
24034         uint64_t ret_ref = (uint64_t)ret_copy;
24035         return ret_ref;
24036 }
24037
24038 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
24039         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24040         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
24041         uint64_t ret_ref = (uint64_t)ret_copy;
24042         return ret_ref;
24043 }
24044
24045 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
24046         LDKPublicKey node_id_ref;
24047         CHECK(*((uint32_t*)node_id) == 33);
24048         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
24049         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24050         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
24051         uint64_t ret_ref = (uint64_t)ret_copy;
24052         return ret_ref;
24053 }
24054
24055 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
24056         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
24057         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
24058         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24059         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24060         CVec_u8Z_free(ret_var);
24061         return ret_arr;
24062 }
24063
24064 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
24065         LDKNetGraphMsgHandler this_arg_conv;
24066         this_arg_conv.inner = (void*)(this_arg & (~1));
24067         this_arg_conv.is_owned = false;
24068         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
24069         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
24070         return (uint64_t)ret_ret;
24071 }
24072
24073 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
24074         LDKNetGraphMsgHandler this_obj_conv;
24075         this_obj_conv.inner = (void*)(this_obj & (~1));
24076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24077         NetGraphMsgHandler_free(this_obj_conv);
24078 }
24079
24080 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_get_network_graph(uint32_t this_ptr) {
24081         LDKNetGraphMsgHandler this_ptr_conv;
24082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24083         this_ptr_conv.is_owned = false;
24084         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
24085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24087         uint64_t ret_ref = (uint64_t)ret_var.inner;
24088         if (ret_var.is_owned) {
24089                 ret_ref |= 1;
24090         }
24091         return ret_ref;
24092 }
24093
24094 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_set_network_graph(uint32_t this_ptr, uint32_t val) {
24095         LDKNetGraphMsgHandler this_ptr_conv;
24096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24097         this_ptr_conv.is_owned = false;
24098         LDKNetworkGraph val_conv;
24099         val_conv.inner = (void*)(val & (~1));
24100         val_conv.is_owned = (val & 1) || (val == 0);
24101         val_conv = NetworkGraph_clone(&val_conv);
24102         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
24103 }
24104
24105 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
24106         LDKNetworkGraph network_graph_conv;
24107         network_graph_conv.inner = (void*)(network_graph & (~1));
24108         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24109         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24110         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24111         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24112         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24113                 // Manually implement clone for Java trait instances
24114         }
24115         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24116         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
24117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24119         uint64_t ret_ref = (uint64_t)ret_var.inner;
24120         if (ret_var.is_owned) {
24121                 ret_ref |= 1;
24122         }
24123         return ret_ref;
24124 }
24125
24126 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
24127         LDKNetGraphMsgHandler this_arg_conv;
24128         this_arg_conv.inner = (void*)(this_arg & (~1));
24129         this_arg_conv.is_owned = false;
24130         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24131         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24132         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24133                 // Manually implement clone for Java trait instances
24134         }
24135         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
24136 }
24137
24138 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
24139         LDKNetGraphMsgHandler this_arg_conv;
24140         this_arg_conv.inner = (void*)(this_arg & (~1));
24141         this_arg_conv.is_owned = false;
24142         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24143         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24144         return (uint64_t)ret_ret;
24145 }
24146
24147 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
24148         LDKNetGraphMsgHandler this_arg_conv;
24149         this_arg_conv.inner = (void*)(this_arg & (~1));
24150         this_arg_conv.is_owned = false;
24151         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24152         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24153         return (uint64_t)ret_ret;
24154 }
24155
24156 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
24157         LDKDirectionalChannelInfo this_obj_conv;
24158         this_obj_conv.inner = (void*)(this_obj & (~1));
24159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24160         DirectionalChannelInfo_free(this_obj_conv);
24161 }
24162
24163 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
24164         LDKDirectionalChannelInfo this_ptr_conv;
24165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24166         this_ptr_conv.is_owned = false;
24167         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24168         return ret_val;
24169 }
24170
24171 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
24172         LDKDirectionalChannelInfo this_ptr_conv;
24173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24174         this_ptr_conv.is_owned = false;
24175         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24176 }
24177
24178 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
24179         LDKDirectionalChannelInfo this_ptr_conv;
24180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24181         this_ptr_conv.is_owned = false;
24182         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24183         return ret_val;
24184 }
24185
24186 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
24187         LDKDirectionalChannelInfo this_ptr_conv;
24188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24189         this_ptr_conv.is_owned = false;
24190         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24191 }
24192
24193 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24194         LDKDirectionalChannelInfo this_ptr_conv;
24195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24196         this_ptr_conv.is_owned = false;
24197         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24198         return ret_val;
24199 }
24200
24201 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24202         LDKDirectionalChannelInfo this_ptr_conv;
24203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24204         this_ptr_conv.is_owned = false;
24205         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24206 }
24207
24208 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
24209         LDKDirectionalChannelInfo this_ptr_conv;
24210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24211         this_ptr_conv.is_owned = false;
24212         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24213         return ret_val;
24214 }
24215
24216 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
24217         LDKDirectionalChannelInfo this_ptr_conv;
24218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24219         this_ptr_conv.is_owned = false;
24220         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24221 }
24222
24223 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
24224         LDKDirectionalChannelInfo this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24228         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24229         uint64_t ret_ref = (uint64_t)ret_copy;
24230         return ret_ref;
24231 }
24232
24233 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
24234         LDKDirectionalChannelInfo this_ptr_conv;
24235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24236         this_ptr_conv.is_owned = false;
24237         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24238         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24239         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24240 }
24241
24242 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
24243         LDKDirectionalChannelInfo this_ptr_conv;
24244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24245         this_ptr_conv.is_owned = false;
24246         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24249         uint64_t ret_ref = (uint64_t)ret_var.inner;
24250         if (ret_var.is_owned) {
24251                 ret_ref |= 1;
24252         }
24253         return ret_ref;
24254 }
24255
24256 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
24257         LDKDirectionalChannelInfo this_ptr_conv;
24258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24259         this_ptr_conv.is_owned = false;
24260         LDKRoutingFees val_conv;
24261         val_conv.inner = (void*)(val & (~1));
24262         val_conv.is_owned = (val & 1) || (val == 0);
24263         val_conv = RoutingFees_clone(&val_conv);
24264         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24265 }
24266
24267 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
24268         LDKDirectionalChannelInfo this_ptr_conv;
24269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24270         this_ptr_conv.is_owned = false;
24271         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24274         uint64_t ret_ref = (uint64_t)ret_var.inner;
24275         if (ret_var.is_owned) {
24276                 ret_ref |= 1;
24277         }
24278         return ret_ref;
24279 }
24280
24281 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
24282         LDKDirectionalChannelInfo this_ptr_conv;
24283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24284         this_ptr_conv.is_owned = false;
24285         LDKChannelUpdate val_conv;
24286         val_conv.inner = (void*)(val & (~1));
24287         val_conv.is_owned = (val & 1) || (val == 0);
24288         val_conv = ChannelUpdate_clone(&val_conv);
24289         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24290 }
24291
24292 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) {
24293         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24294         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
24295         LDKRoutingFees fees_arg_conv;
24296         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24297         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24298         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24299         LDKChannelUpdate last_update_message_arg_conv;
24300         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24301         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24302         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24303         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);
24304         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24305         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24306         uint64_t ret_ref = (uint64_t)ret_var.inner;
24307         if (ret_var.is_owned) {
24308                 ret_ref |= 1;
24309         }
24310         return ret_ref;
24311 }
24312
24313 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
24314         LDKDirectionalChannelInfo orig_conv;
24315         orig_conv.inner = (void*)(orig & (~1));
24316         orig_conv.is_owned = false;
24317         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24318         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24319         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24320         uint64_t ret_ref = (uint64_t)ret_var.inner;
24321         if (ret_var.is_owned) {
24322                 ret_ref |= 1;
24323         }
24324         return ret_ref;
24325 }
24326
24327 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
24328         LDKDirectionalChannelInfo obj_conv;
24329         obj_conv.inner = (void*)(obj & (~1));
24330         obj_conv.is_owned = false;
24331         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24332         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24333         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24334         CVec_u8Z_free(ret_var);
24335         return ret_arr;
24336 }
24337
24338 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
24339         LDKu8slice ser_ref;
24340         ser_ref.datalen = *((uint32_t*)ser);
24341         ser_ref.data = (int8_t*)(ser + 4);
24342         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24343         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24344         return (uint64_t)ret_conv;
24345 }
24346
24347 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
24348         LDKChannelInfo this_obj_conv;
24349         this_obj_conv.inner = (void*)(this_obj & (~1));
24350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24351         ChannelInfo_free(this_obj_conv);
24352 }
24353
24354 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
24355         LDKChannelInfo this_ptr_conv;
24356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24357         this_ptr_conv.is_owned = false;
24358         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24359         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24360         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24361         uint64_t ret_ref = (uint64_t)ret_var.inner;
24362         if (ret_var.is_owned) {
24363                 ret_ref |= 1;
24364         }
24365         return ret_ref;
24366 }
24367
24368 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
24369         LDKChannelInfo this_ptr_conv;
24370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24371         this_ptr_conv.is_owned = false;
24372         LDKChannelFeatures val_conv;
24373         val_conv.inner = (void*)(val & (~1));
24374         val_conv.is_owned = (val & 1) || (val == 0);
24375         val_conv = ChannelFeatures_clone(&val_conv);
24376         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24377 }
24378
24379 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
24380         LDKChannelInfo this_ptr_conv;
24381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24382         this_ptr_conv.is_owned = false;
24383         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
24384         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24385         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24386         uint64_t ret_ref = (uint64_t)ret_var.inner;
24387         if (ret_var.is_owned) {
24388                 ret_ref |= 1;
24389         }
24390         return ret_ref;
24391 }
24392
24393 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
24394         LDKChannelInfo this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         LDKNodeId val_conv;
24398         val_conv.inner = (void*)(val & (~1));
24399         val_conv.is_owned = (val & 1) || (val == 0);
24400         val_conv = NodeId_clone(&val_conv);
24401         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
24402 }
24403
24404 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
24405         LDKChannelInfo this_ptr_conv;
24406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24407         this_ptr_conv.is_owned = false;
24408         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24411         uint64_t ret_ref = (uint64_t)ret_var.inner;
24412         if (ret_var.is_owned) {
24413                 ret_ref |= 1;
24414         }
24415         return ret_ref;
24416 }
24417
24418 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
24419         LDKChannelInfo this_ptr_conv;
24420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24421         this_ptr_conv.is_owned = false;
24422         LDKDirectionalChannelInfo val_conv;
24423         val_conv.inner = (void*)(val & (~1));
24424         val_conv.is_owned = (val & 1) || (val == 0);
24425         val_conv = DirectionalChannelInfo_clone(&val_conv);
24426         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24427 }
24428
24429 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_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         LDKNodeId ret_var = ChannelInfo_get_node_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_node_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         LDKNodeId val_conv;
24448         val_conv.inner = (void*)(val & (~1));
24449         val_conv.is_owned = (val & 1) || (val == 0);
24450         val_conv = NodeId_clone(&val_conv);
24451         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
24452 }
24453
24454 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(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         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24461         uint64_t ret_ref = (uint64_t)ret_var.inner;
24462         if (ret_var.is_owned) {
24463                 ret_ref |= 1;
24464         }
24465         return ret_ref;
24466 }
24467
24468 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
24469         LDKChannelInfo this_ptr_conv;
24470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24471         this_ptr_conv.is_owned = false;
24472         LDKDirectionalChannelInfo val_conv;
24473         val_conv.inner = (void*)(val & (~1));
24474         val_conv.is_owned = (val & 1) || (val == 0);
24475         val_conv = DirectionalChannelInfo_clone(&val_conv);
24476         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24477 }
24478
24479 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
24480         LDKChannelInfo this_ptr_conv;
24481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24482         this_ptr_conv.is_owned = false;
24483         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24484         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24485         uint64_t ret_ref = (uint64_t)ret_copy;
24486         return ret_ref;
24487 }
24488
24489 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
24490         LDKChannelInfo this_ptr_conv;
24491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24492         this_ptr_conv.is_owned = false;
24493         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24494         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24495         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24496 }
24497
24498 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(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         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24505         uint64_t ret_ref = (uint64_t)ret_var.inner;
24506         if (ret_var.is_owned) {
24507                 ret_ref |= 1;
24508         }
24509         return ret_ref;
24510 }
24511
24512 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24513         LDKChannelInfo this_ptr_conv;
24514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24515         this_ptr_conv.is_owned = false;
24516         LDKChannelAnnouncement val_conv;
24517         val_conv.inner = (void*)(val & (~1));
24518         val_conv.is_owned = (val & 1) || (val == 0);
24519         val_conv = ChannelAnnouncement_clone(&val_conv);
24520         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24521 }
24522
24523 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, uint32_t node_one_arg, uint32_t one_to_two_arg, uint32_t node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
24524         LDKChannelFeatures features_arg_conv;
24525         features_arg_conv.inner = (void*)(features_arg & (~1));
24526         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24527         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24528         LDKNodeId node_one_arg_conv;
24529         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
24530         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
24531         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
24532         LDKDirectionalChannelInfo one_to_two_arg_conv;
24533         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24534         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24535         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24536         LDKNodeId node_two_arg_conv;
24537         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
24538         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
24539         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
24540         LDKDirectionalChannelInfo two_to_one_arg_conv;
24541         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24542         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24543         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24544         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24545         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
24546         LDKChannelAnnouncement announcement_message_arg_conv;
24547         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24548         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24549         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24550         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
24551         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24552         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24553         uint64_t ret_ref = (uint64_t)ret_var.inner;
24554         if (ret_var.is_owned) {
24555                 ret_ref |= 1;
24556         }
24557         return ret_ref;
24558 }
24559
24560 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
24561         LDKChannelInfo orig_conv;
24562         orig_conv.inner = (void*)(orig & (~1));
24563         orig_conv.is_owned = false;
24564         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24567         uint64_t ret_ref = (uint64_t)ret_var.inner;
24568         if (ret_var.is_owned) {
24569                 ret_ref |= 1;
24570         }
24571         return ret_ref;
24572 }
24573
24574 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
24575         LDKChannelInfo obj_conv;
24576         obj_conv.inner = (void*)(obj & (~1));
24577         obj_conv.is_owned = false;
24578         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24579         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24580         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24581         CVec_u8Z_free(ret_var);
24582         return ret_arr;
24583 }
24584
24585 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
24586         LDKu8slice ser_ref;
24587         ser_ref.datalen = *((uint32_t*)ser);
24588         ser_ref.data = (int8_t*)(ser + 4);
24589         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24590         *ret_conv = ChannelInfo_read(ser_ref);
24591         return (uint64_t)ret_conv;
24592 }
24593
24594 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
24595         LDKRoutingFees this_obj_conv;
24596         this_obj_conv.inner = (void*)(this_obj & (~1));
24597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24598         RoutingFees_free(this_obj_conv);
24599 }
24600
24601 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
24602         LDKRoutingFees this_ptr_conv;
24603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24604         this_ptr_conv.is_owned = false;
24605         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24606         return ret_val;
24607 }
24608
24609 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
24610         LDKRoutingFees this_ptr_conv;
24611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24612         this_ptr_conv.is_owned = false;
24613         RoutingFees_set_base_msat(&this_ptr_conv, val);
24614 }
24615
24616 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
24617         LDKRoutingFees this_ptr_conv;
24618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24619         this_ptr_conv.is_owned = false;
24620         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24621         return ret_val;
24622 }
24623
24624 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
24625         LDKRoutingFees this_ptr_conv;
24626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24627         this_ptr_conv.is_owned = false;
24628         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24629 }
24630
24631 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
24632         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
24633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24635         uint64_t ret_ref = (uint64_t)ret_var.inner;
24636         if (ret_var.is_owned) {
24637                 ret_ref |= 1;
24638         }
24639         return ret_ref;
24640 }
24641
24642 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
24643         LDKRoutingFees a_conv;
24644         a_conv.inner = (void*)(a & (~1));
24645         a_conv.is_owned = false;
24646         LDKRoutingFees b_conv;
24647         b_conv.inner = (void*)(b & (~1));
24648         b_conv.is_owned = false;
24649         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24650         return ret_val;
24651 }
24652
24653 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
24654         LDKRoutingFees orig_conv;
24655         orig_conv.inner = (void*)(orig & (~1));
24656         orig_conv.is_owned = false;
24657         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24660         uint64_t ret_ref = (uint64_t)ret_var.inner;
24661         if (ret_var.is_owned) {
24662                 ret_ref |= 1;
24663         }
24664         return ret_ref;
24665 }
24666
24667 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
24668         LDKRoutingFees o_conv;
24669         o_conv.inner = (void*)(o & (~1));
24670         o_conv.is_owned = false;
24671         int64_t ret_val = RoutingFees_hash(&o_conv);
24672         return ret_val;
24673 }
24674
24675 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
24676         LDKRoutingFees obj_conv;
24677         obj_conv.inner = (void*)(obj & (~1));
24678         obj_conv.is_owned = false;
24679         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24680         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24681         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24682         CVec_u8Z_free(ret_var);
24683         return ret_arr;
24684 }
24685
24686 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
24687         LDKu8slice ser_ref;
24688         ser_ref.datalen = *((uint32_t*)ser);
24689         ser_ref.data = (int8_t*)(ser + 4);
24690         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24691         *ret_conv = RoutingFees_read(ser_ref);
24692         return (uint64_t)ret_conv;
24693 }
24694
24695 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
24696         LDKNodeAnnouncementInfo this_obj_conv;
24697         this_obj_conv.inner = (void*)(this_obj & (~1));
24698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24699         NodeAnnouncementInfo_free(this_obj_conv);
24700 }
24701
24702 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
24703         LDKNodeAnnouncementInfo this_ptr_conv;
24704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24705         this_ptr_conv.is_owned = false;
24706         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24709         uint64_t ret_ref = (uint64_t)ret_var.inner;
24710         if (ret_var.is_owned) {
24711                 ret_ref |= 1;
24712         }
24713         return ret_ref;
24714 }
24715
24716 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
24717         LDKNodeAnnouncementInfo this_ptr_conv;
24718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24719         this_ptr_conv.is_owned = false;
24720         LDKNodeFeatures val_conv;
24721         val_conv.inner = (void*)(val & (~1));
24722         val_conv.is_owned = (val & 1) || (val == 0);
24723         val_conv = NodeFeatures_clone(&val_conv);
24724         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24725 }
24726
24727 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
24728         LDKNodeAnnouncementInfo this_ptr_conv;
24729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24730         this_ptr_conv.is_owned = false;
24731         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24732         return ret_val;
24733 }
24734
24735 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
24736         LDKNodeAnnouncementInfo this_ptr_conv;
24737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24738         this_ptr_conv.is_owned = false;
24739         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24740 }
24741
24742 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
24743         LDKNodeAnnouncementInfo this_ptr_conv;
24744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24745         this_ptr_conv.is_owned = false;
24746         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
24747         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
24748         return ret_arr;
24749 }
24750
24751 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
24752         LDKNodeAnnouncementInfo this_ptr_conv;
24753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24754         this_ptr_conv.is_owned = false;
24755         LDKThreeBytes val_ref;
24756         CHECK(*((uint32_t*)val) == 3);
24757         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
24758         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24759 }
24760
24761 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
24762         LDKNodeAnnouncementInfo this_ptr_conv;
24763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24764         this_ptr_conv.is_owned = false;
24765         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24766         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
24767         return ret_arr;
24768 }
24769
24770 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
24771         LDKNodeAnnouncementInfo this_ptr_conv;
24772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24773         this_ptr_conv.is_owned = false;
24774         LDKThirtyTwoBytes val_ref;
24775         CHECK(*((uint32_t*)val) == 32);
24776         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24777         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24778 }
24779
24780 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
24781         LDKNodeAnnouncementInfo this_ptr_conv;
24782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24783         this_ptr_conv.is_owned = false;
24784         LDKCVec_NetAddressZ val_constr;
24785         val_constr.datalen = *((uint32_t*)val);
24786         if (val_constr.datalen > 0)
24787                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24788         else
24789                 val_constr.data = NULL;
24790         uint32_t* val_vals = (uint32_t*)(val + 4);
24791         for (size_t m = 0; m < val_constr.datalen; m++) {
24792                 uint32_t val_conv_12 = val_vals[m];
24793                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24794                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24795                 val_constr.data[m] = val_conv_12_conv;
24796         }
24797         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24798 }
24799
24800 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
24801         LDKNodeAnnouncementInfo this_ptr_conv;
24802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24803         this_ptr_conv.is_owned = false;
24804         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24807         uint64_t ret_ref = (uint64_t)ret_var.inner;
24808         if (ret_var.is_owned) {
24809                 ret_ref |= 1;
24810         }
24811         return ret_ref;
24812 }
24813
24814 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24815         LDKNodeAnnouncementInfo this_ptr_conv;
24816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24817         this_ptr_conv.is_owned = false;
24818         LDKNodeAnnouncement val_conv;
24819         val_conv.inner = (void*)(val & (~1));
24820         val_conv.is_owned = (val & 1) || (val == 0);
24821         val_conv = NodeAnnouncement_clone(&val_conv);
24822         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24823 }
24824
24825 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) {
24826         LDKNodeFeatures features_arg_conv;
24827         features_arg_conv.inner = (void*)(features_arg & (~1));
24828         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24829         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24830         LDKThreeBytes rgb_arg_ref;
24831         CHECK(*((uint32_t*)rgb_arg) == 3);
24832         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
24833         LDKThirtyTwoBytes alias_arg_ref;
24834         CHECK(*((uint32_t*)alias_arg) == 32);
24835         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
24836         LDKCVec_NetAddressZ addresses_arg_constr;
24837         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
24838         if (addresses_arg_constr.datalen > 0)
24839                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24840         else
24841                 addresses_arg_constr.data = NULL;
24842         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
24843         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24844                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
24845                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24846                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24847         }
24848         LDKNodeAnnouncement announcement_message_arg_conv;
24849         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24850         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24851         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24852         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24855         uint64_t ret_ref = (uint64_t)ret_var.inner;
24856         if (ret_var.is_owned) {
24857                 ret_ref |= 1;
24858         }
24859         return ret_ref;
24860 }
24861
24862 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
24863         LDKNodeAnnouncementInfo orig_conv;
24864         orig_conv.inner = (void*)(orig & (~1));
24865         orig_conv.is_owned = false;
24866         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24869         uint64_t ret_ref = (uint64_t)ret_var.inner;
24870         if (ret_var.is_owned) {
24871                 ret_ref |= 1;
24872         }
24873         return ret_ref;
24874 }
24875
24876 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
24877         LDKNodeAnnouncementInfo obj_conv;
24878         obj_conv.inner = (void*)(obj & (~1));
24879         obj_conv.is_owned = false;
24880         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24881         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24882         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24883         CVec_u8Z_free(ret_var);
24884         return ret_arr;
24885 }
24886
24887 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
24888         LDKu8slice ser_ref;
24889         ser_ref.datalen = *((uint32_t*)ser);
24890         ser_ref.data = (int8_t*)(ser + 4);
24891         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24892         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24893         return (uint64_t)ret_conv;
24894 }
24895
24896 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
24897         LDKNodeInfo this_obj_conv;
24898         this_obj_conv.inner = (void*)(this_obj & (~1));
24899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24900         NodeInfo_free(this_obj_conv);
24901 }
24902
24903 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
24904         LDKNodeInfo this_ptr_conv;
24905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24906         this_ptr_conv.is_owned = false;
24907         LDKCVec_u64Z val_constr;
24908         val_constr.datalen = *((uint32_t*)val);
24909         if (val_constr.datalen > 0)
24910                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24911         else
24912                 val_constr.data = NULL;
24913         int64_t* val_vals = (int64_t*)(val + 4);
24914         for (size_t i = 0; i < val_constr.datalen; i++) {
24915                 int64_t val_conv_8 = val_vals[i];
24916                 val_constr.data[i] = val_conv_8;
24917         }
24918         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24919 }
24920
24921 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
24922         LDKNodeInfo this_ptr_conv;
24923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24924         this_ptr_conv.is_owned = false;
24925         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24926         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24927         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24928         uint64_t ret_ref = (uint64_t)ret_var.inner;
24929         if (ret_var.is_owned) {
24930                 ret_ref |= 1;
24931         }
24932         return ret_ref;
24933 }
24934
24935 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
24936         LDKNodeInfo this_ptr_conv;
24937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24938         this_ptr_conv.is_owned = false;
24939         LDKRoutingFees val_conv;
24940         val_conv.inner = (void*)(val & (~1));
24941         val_conv.is_owned = (val & 1) || (val == 0);
24942         val_conv = RoutingFees_clone(&val_conv);
24943         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24944 }
24945
24946 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
24947         LDKNodeInfo this_ptr_conv;
24948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24949         this_ptr_conv.is_owned = false;
24950         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24953         uint64_t ret_ref = (uint64_t)ret_var.inner;
24954         if (ret_var.is_owned) {
24955                 ret_ref |= 1;
24956         }
24957         return ret_ref;
24958 }
24959
24960 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
24961         LDKNodeInfo this_ptr_conv;
24962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24963         this_ptr_conv.is_owned = false;
24964         LDKNodeAnnouncementInfo val_conv;
24965         val_conv.inner = (void*)(val & (~1));
24966         val_conv.is_owned = (val & 1) || (val == 0);
24967         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24968         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24969 }
24970
24971 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
24972         LDKCVec_u64Z channels_arg_constr;
24973         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
24974         if (channels_arg_constr.datalen > 0)
24975                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24976         else
24977                 channels_arg_constr.data = NULL;
24978         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
24979         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
24980                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
24981                 channels_arg_constr.data[i] = channels_arg_conv_8;
24982         }
24983         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
24984         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
24985         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
24986         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
24987         LDKNodeAnnouncementInfo announcement_info_arg_conv;
24988         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
24989         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
24990         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
24991         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
24992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24994         uint64_t ret_ref = (uint64_t)ret_var.inner;
24995         if (ret_var.is_owned) {
24996                 ret_ref |= 1;
24997         }
24998         return ret_ref;
24999 }
25000
25001 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
25002         LDKNodeInfo orig_conv;
25003         orig_conv.inner = (void*)(orig & (~1));
25004         orig_conv.is_owned = false;
25005         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25008         uint64_t ret_ref = (uint64_t)ret_var.inner;
25009         if (ret_var.is_owned) {
25010                 ret_ref |= 1;
25011         }
25012         return ret_ref;
25013 }
25014
25015 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
25016         LDKNodeInfo obj_conv;
25017         obj_conv.inner = (void*)(obj & (~1));
25018         obj_conv.is_owned = false;
25019         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25020         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25021         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25022         CVec_u8Z_free(ret_var);
25023         return ret_arr;
25024 }
25025
25026 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
25027         LDKu8slice ser_ref;
25028         ser_ref.datalen = *((uint32_t*)ser);
25029         ser_ref.data = (int8_t*)(ser + 4);
25030         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25031         *ret_conv = NodeInfo_read(ser_ref);
25032         return (uint64_t)ret_conv;
25033 }
25034
25035 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
25036         LDKNetworkGraph obj_conv;
25037         obj_conv.inner = (void*)(obj & (~1));
25038         obj_conv.is_owned = false;
25039         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25040         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25041         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25042         CVec_u8Z_free(ret_var);
25043         return ret_arr;
25044 }
25045
25046 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
25047         LDKu8slice ser_ref;
25048         ser_ref.datalen = *((uint32_t*)ser);
25049         ser_ref.data = (int8_t*)(ser + 4);
25050         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25051         *ret_conv = NetworkGraph_read(ser_ref);
25052         return (uint64_t)ret_conv;
25053 }
25054
25055 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
25056         LDKThirtyTwoBytes genesis_hash_ref;
25057         CHECK(*((uint32_t*)genesis_hash) == 32);
25058         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
25059         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25062         uint64_t ret_ref = (uint64_t)ret_var.inner;
25063         if (ret_var.is_owned) {
25064                 ret_ref |= 1;
25065         }
25066         return ret_ref;
25067 }
25068
25069 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
25070         LDKNetworkGraph this_arg_conv;
25071         this_arg_conv.inner = (void*)(this_arg & (~1));
25072         this_arg_conv.is_owned = false;
25073         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
25074         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25075         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25076         uint64_t ret_ref = (uint64_t)ret_var.inner;
25077         if (ret_var.is_owned) {
25078                 ret_ref |= 1;
25079         }
25080         return ret_ref;
25081 }
25082
25083 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
25084         LDKNetworkGraph this_arg_conv;
25085         this_arg_conv.inner = (void*)(this_arg & (~1));
25086         this_arg_conv.is_owned = false;
25087         LDKNodeAnnouncement msg_conv;
25088         msg_conv.inner = (void*)(msg & (~1));
25089         msg_conv.is_owned = false;
25090         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25091         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25092         return (uint64_t)ret_conv;
25093 }
25094
25095 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
25096         LDKNetworkGraph this_arg_conv;
25097         this_arg_conv.inner = (void*)(this_arg & (~1));
25098         this_arg_conv.is_owned = false;
25099         LDKUnsignedNodeAnnouncement msg_conv;
25100         msg_conv.inner = (void*)(msg & (~1));
25101         msg_conv.is_owned = false;
25102         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25103         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25104         return (uint64_t)ret_conv;
25105 }
25106
25107 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
25108         LDKNetworkGraph this_arg_conv;
25109         this_arg_conv.inner = (void*)(this_arg & (~1));
25110         this_arg_conv.is_owned = false;
25111         LDKChannelAnnouncement msg_conv;
25112         msg_conv.inner = (void*)(msg & (~1));
25113         msg_conv.is_owned = false;
25114         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
25115         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
25116         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
25117                 // Manually implement clone for Java trait instances
25118         }
25119         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25120         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
25121         return (uint64_t)ret_conv;
25122 }
25123
25124 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_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         LDKUnsignedChannelAnnouncement 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_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
25138         return (uint64_t)ret_conv;
25139 }
25140
25141 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
25142         LDKNetworkGraph this_arg_conv;
25143         this_arg_conv.inner = (void*)(this_arg & (~1));
25144         this_arg_conv.is_owned = false;
25145         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25146 }
25147
25148 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
25149         LDKNetworkGraph this_arg_conv;
25150         this_arg_conv.inner = (void*)(this_arg & (~1));
25151         this_arg_conv.is_owned = false;
25152         LDKPublicKey _node_id_ref;
25153         CHECK(*((uint32_t*)_node_id) == 33);
25154         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
25155         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
25156 }
25157
25158 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
25159         LDKNetworkGraph this_arg_conv;
25160         this_arg_conv.inner = (void*)(this_arg & (~1));
25161         this_arg_conv.is_owned = false;
25162         LDKChannelUpdate msg_conv;
25163         msg_conv.inner = (void*)(msg & (~1));
25164         msg_conv.is_owned = false;
25165         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25166         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25167         return (uint64_t)ret_conv;
25168 }
25169
25170 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
25171         LDKNetworkGraph this_arg_conv;
25172         this_arg_conv.inner = (void*)(this_arg & (~1));
25173         this_arg_conv.is_owned = false;
25174         LDKUnsignedChannelUpdate msg_conv;
25175         msg_conv.inner = (void*)(msg & (~1));
25176         msg_conv.is_owned = false;
25177         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25178         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25179         return (uint64_t)ret_conv;
25180 }
25181
25182 uint32_t  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
25183         LDKReadOnlyNetworkGraph this_arg_conv;
25184         this_arg_conv.inner = (void*)(this_arg & (~1));
25185         this_arg_conv.is_owned = false;
25186         LDKPublicKey pubkey_ref;
25187         CHECK(*((uint32_t*)pubkey) == 33);
25188         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
25189         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
25190         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
25191         uint64_t ret_ref = (uint64_t)ret_copy;
25192         return ret_ref;
25193 }
25194
25195 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
25196         LDKRouteHop this_obj_conv;
25197         this_obj_conv.inner = (void*)(this_obj & (~1));
25198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25199         RouteHop_free(this_obj_conv);
25200 }
25201
25202 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
25203         LDKRouteHop this_ptr_conv;
25204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25205         this_ptr_conv.is_owned = false;
25206         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25207         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
25208         return ret_arr;
25209 }
25210
25211 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
25212         LDKRouteHop this_ptr_conv;
25213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25214         this_ptr_conv.is_owned = false;
25215         LDKPublicKey val_ref;
25216         CHECK(*((uint32_t*)val) == 33);
25217         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25218         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
25219 }
25220
25221 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
25222         LDKRouteHop this_ptr_conv;
25223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25224         this_ptr_conv.is_owned = false;
25225         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
25226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25228         uint64_t ret_ref = (uint64_t)ret_var.inner;
25229         if (ret_var.is_owned) {
25230                 ret_ref |= 1;
25231         }
25232         return ret_ref;
25233 }
25234
25235 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
25236         LDKRouteHop this_ptr_conv;
25237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25238         this_ptr_conv.is_owned = false;
25239         LDKNodeFeatures val_conv;
25240         val_conv.inner = (void*)(val & (~1));
25241         val_conv.is_owned = (val & 1) || (val == 0);
25242         val_conv = NodeFeatures_clone(&val_conv);
25243         RouteHop_set_node_features(&this_ptr_conv, val_conv);
25244 }
25245
25246 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
25247         LDKRouteHop this_ptr_conv;
25248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25249         this_ptr_conv.is_owned = false;
25250         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
25251         return ret_val;
25252 }
25253
25254 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25255         LDKRouteHop this_ptr_conv;
25256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25257         this_ptr_conv.is_owned = false;
25258         RouteHop_set_short_channel_id(&this_ptr_conv, val);
25259 }
25260
25261 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
25262         LDKRouteHop this_ptr_conv;
25263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25264         this_ptr_conv.is_owned = false;
25265         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
25266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25268         uint64_t ret_ref = (uint64_t)ret_var.inner;
25269         if (ret_var.is_owned) {
25270                 ret_ref |= 1;
25271         }
25272         return ret_ref;
25273 }
25274
25275 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
25276         LDKRouteHop this_ptr_conv;
25277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25278         this_ptr_conv.is_owned = false;
25279         LDKChannelFeatures val_conv;
25280         val_conv.inner = (void*)(val & (~1));
25281         val_conv.is_owned = (val & 1) || (val == 0);
25282         val_conv = ChannelFeatures_clone(&val_conv);
25283         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
25284 }
25285
25286 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
25287         LDKRouteHop this_ptr_conv;
25288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25289         this_ptr_conv.is_owned = false;
25290         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
25291         return ret_val;
25292 }
25293
25294 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
25295         LDKRouteHop this_ptr_conv;
25296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25297         this_ptr_conv.is_owned = false;
25298         RouteHop_set_fee_msat(&this_ptr_conv, val);
25299 }
25300
25301 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
25302         LDKRouteHop this_ptr_conv;
25303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25304         this_ptr_conv.is_owned = false;
25305         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
25306         return ret_val;
25307 }
25308
25309 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
25310         LDKRouteHop this_ptr_conv;
25311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25312         this_ptr_conv.is_owned = false;
25313         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
25314 }
25315
25316 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) {
25317         LDKPublicKey pubkey_arg_ref;
25318         CHECK(*((uint32_t*)pubkey_arg) == 33);
25319         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
25320         LDKNodeFeatures node_features_arg_conv;
25321         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
25322         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
25323         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
25324         LDKChannelFeatures channel_features_arg_conv;
25325         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
25326         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
25327         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
25328         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);
25329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25331         uint64_t ret_ref = (uint64_t)ret_var.inner;
25332         if (ret_var.is_owned) {
25333                 ret_ref |= 1;
25334         }
25335         return ret_ref;
25336 }
25337
25338 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
25339         LDKRouteHop orig_conv;
25340         orig_conv.inner = (void*)(orig & (~1));
25341         orig_conv.is_owned = false;
25342         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
25343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25345         uint64_t ret_ref = (uint64_t)ret_var.inner;
25346         if (ret_var.is_owned) {
25347                 ret_ref |= 1;
25348         }
25349         return ret_ref;
25350 }
25351
25352 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
25353         LDKRouteHop o_conv;
25354         o_conv.inner = (void*)(o & (~1));
25355         o_conv.is_owned = false;
25356         int64_t ret_val = RouteHop_hash(&o_conv);
25357         return ret_val;
25358 }
25359
25360 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
25361         LDKRouteHop a_conv;
25362         a_conv.inner = (void*)(a & (~1));
25363         a_conv.is_owned = false;
25364         LDKRouteHop b_conv;
25365         b_conv.inner = (void*)(b & (~1));
25366         b_conv.is_owned = false;
25367         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
25368         return ret_val;
25369 }
25370
25371 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
25372         LDKRouteHop obj_conv;
25373         obj_conv.inner = (void*)(obj & (~1));
25374         obj_conv.is_owned = false;
25375         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
25376         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25377         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25378         CVec_u8Z_free(ret_var);
25379         return ret_arr;
25380 }
25381
25382 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
25383         LDKu8slice ser_ref;
25384         ser_ref.datalen = *((uint32_t*)ser);
25385         ser_ref.data = (int8_t*)(ser + 4);
25386         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
25387         *ret_conv = RouteHop_read(ser_ref);
25388         return (uint64_t)ret_conv;
25389 }
25390
25391 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
25392         LDKRoute this_obj_conv;
25393         this_obj_conv.inner = (void*)(this_obj & (~1));
25394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25395         Route_free(this_obj_conv);
25396 }
25397
25398 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
25399         LDKRoute this_ptr_conv;
25400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25401         this_ptr_conv.is_owned = false;
25402         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
25403         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
25404         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
25405         for (size_t m = 0; m < ret_var.datalen; m++) {
25406                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
25407                 uint32_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
25408                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
25409                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
25410                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
25411                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25412                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25413                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
25414                         if (ret_conv_12_conv_10_var.is_owned) {
25415                                 ret_conv_12_conv_10_ref |= 1;
25416                         }
25417                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
25418                 }
25419                 FREE(ret_conv_12_var.data);
25420                 ret_arr_ptr[m] = ret_conv_12_arr;
25421         }
25422         FREE(ret_var.data);
25423         return ret_arr;
25424 }
25425
25426 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
25427         LDKRoute this_ptr_conv;
25428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25429         this_ptr_conv.is_owned = false;
25430         LDKCVec_CVec_RouteHopZZ val_constr;
25431         val_constr.datalen = *((uint32_t*)val);
25432         if (val_constr.datalen > 0)
25433                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
25434         else
25435                 val_constr.data = NULL;
25436         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
25437         for (size_t m = 0; m < val_constr.datalen; m++) {
25438                 uint32_tArray val_conv_12 = val_vals[m];
25439                 LDKCVec_RouteHopZ val_conv_12_constr;
25440                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
25441                 if (val_conv_12_constr.datalen > 0)
25442                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25443                 else
25444                         val_conv_12_constr.data = NULL;
25445                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
25446                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
25447                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
25448                         LDKRouteHop val_conv_12_conv_10_conv;
25449                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
25450                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
25451                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
25452                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
25453                 }
25454                 val_constr.data[m] = val_conv_12_constr;
25455         }
25456         Route_set_paths(&this_ptr_conv, val_constr);
25457 }
25458
25459 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
25460         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
25461         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
25462         if (paths_arg_constr.datalen > 0)
25463                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
25464         else
25465                 paths_arg_constr.data = NULL;
25466         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
25467         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
25468                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
25469                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
25470                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
25471                 if (paths_arg_conv_12_constr.datalen > 0)
25472                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25473                 else
25474                         paths_arg_conv_12_constr.data = NULL;
25475                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
25476                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
25477                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
25478                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
25479                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
25480                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
25481                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
25482                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
25483                 }
25484                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
25485         }
25486         LDKRoute ret_var = Route_new(paths_arg_constr);
25487         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25488         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25489         uint64_t ret_ref = (uint64_t)ret_var.inner;
25490         if (ret_var.is_owned) {
25491                 ret_ref |= 1;
25492         }
25493         return ret_ref;
25494 }
25495
25496 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
25497         LDKRoute orig_conv;
25498         orig_conv.inner = (void*)(orig & (~1));
25499         orig_conv.is_owned = false;
25500         LDKRoute ret_var = Route_clone(&orig_conv);
25501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25503         uint64_t ret_ref = (uint64_t)ret_var.inner;
25504         if (ret_var.is_owned) {
25505                 ret_ref |= 1;
25506         }
25507         return ret_ref;
25508 }
25509
25510 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
25511         LDKRoute o_conv;
25512         o_conv.inner = (void*)(o & (~1));
25513         o_conv.is_owned = false;
25514         int64_t ret_val = Route_hash(&o_conv);
25515         return ret_val;
25516 }
25517
25518 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
25519         LDKRoute a_conv;
25520         a_conv.inner = (void*)(a & (~1));
25521         a_conv.is_owned = false;
25522         LDKRoute b_conv;
25523         b_conv.inner = (void*)(b & (~1));
25524         b_conv.is_owned = false;
25525         jboolean ret_val = Route_eq(&a_conv, &b_conv);
25526         return ret_val;
25527 }
25528
25529 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
25530         LDKRoute this_arg_conv;
25531         this_arg_conv.inner = (void*)(this_arg & (~1));
25532         this_arg_conv.is_owned = false;
25533         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
25534         return ret_val;
25535 }
25536
25537 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
25538         LDKRoute this_arg_conv;
25539         this_arg_conv.inner = (void*)(this_arg & (~1));
25540         this_arg_conv.is_owned = false;
25541         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
25542         return ret_val;
25543 }
25544
25545 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
25546         LDKRoute obj_conv;
25547         obj_conv.inner = (void*)(obj & (~1));
25548         obj_conv.is_owned = false;
25549         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
25550         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25551         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25552         CVec_u8Z_free(ret_var);
25553         return ret_arr;
25554 }
25555
25556 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
25557         LDKu8slice ser_ref;
25558         ser_ref.datalen = *((uint32_t*)ser);
25559         ser_ref.data = (int8_t*)(ser + 4);
25560         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
25561         *ret_conv = Route_read(ser_ref);
25562         return (uint64_t)ret_conv;
25563 }
25564
25565 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
25566         LDKRouteHint this_obj_conv;
25567         this_obj_conv.inner = (void*)(this_obj & (~1));
25568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25569         RouteHint_free(this_obj_conv);
25570 }
25571
25572 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
25573         LDKRouteHint orig_conv;
25574         orig_conv.inner = (void*)(orig & (~1));
25575         orig_conv.is_owned = false;
25576         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
25577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25579         uint64_t ret_ref = (uint64_t)ret_var.inner;
25580         if (ret_var.is_owned) {
25581                 ret_ref |= 1;
25582         }
25583         return ret_ref;
25584 }
25585
25586 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
25587         LDKRouteHint o_conv;
25588         o_conv.inner = (void*)(o & (~1));
25589         o_conv.is_owned = false;
25590         int64_t ret_val = RouteHint_hash(&o_conv);
25591         return ret_val;
25592 }
25593
25594 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
25595         LDKRouteHint a_conv;
25596         a_conv.inner = (void*)(a & (~1));
25597         a_conv.is_owned = false;
25598         LDKRouteHint b_conv;
25599         b_conv.inner = (void*)(b & (~1));
25600         b_conv.is_owned = false;
25601         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
25602         return ret_val;
25603 }
25604
25605 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
25606         LDKRouteHintHop this_obj_conv;
25607         this_obj_conv.inner = (void*)(this_obj & (~1));
25608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25609         RouteHintHop_free(this_obj_conv);
25610 }
25611
25612 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
25613         LDKRouteHintHop this_ptr_conv;
25614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25615         this_ptr_conv.is_owned = false;
25616         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25617         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
25618         return ret_arr;
25619 }
25620
25621 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
25622         LDKRouteHintHop this_ptr_conv;
25623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25624         this_ptr_conv.is_owned = false;
25625         LDKPublicKey val_ref;
25626         CHECK(*((uint32_t*)val) == 33);
25627         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25628         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
25629 }
25630
25631 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
25632         LDKRouteHintHop this_ptr_conv;
25633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25634         this_ptr_conv.is_owned = false;
25635         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
25636         return ret_val;
25637 }
25638
25639 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25640         LDKRouteHintHop this_ptr_conv;
25641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25642         this_ptr_conv.is_owned = false;
25643         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
25644 }
25645
25646 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
25647         LDKRouteHintHop this_ptr_conv;
25648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25649         this_ptr_conv.is_owned = false;
25650         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
25651         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25652         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25653         uint64_t ret_ref = (uint64_t)ret_var.inner;
25654         if (ret_var.is_owned) {
25655                 ret_ref |= 1;
25656         }
25657         return ret_ref;
25658 }
25659
25660 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
25661         LDKRouteHintHop this_ptr_conv;
25662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25663         this_ptr_conv.is_owned = false;
25664         LDKRoutingFees val_conv;
25665         val_conv.inner = (void*)(val & (~1));
25666         val_conv.is_owned = (val & 1) || (val == 0);
25667         val_conv = RoutingFees_clone(&val_conv);
25668         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
25669 }
25670
25671 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
25672         LDKRouteHintHop this_ptr_conv;
25673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25674         this_ptr_conv.is_owned = false;
25675         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
25676         return ret_val;
25677 }
25678
25679 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25680         LDKRouteHintHop this_ptr_conv;
25681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25682         this_ptr_conv.is_owned = false;
25683         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
25684 }
25685
25686 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
25687         LDKRouteHintHop this_ptr_conv;
25688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25689         this_ptr_conv.is_owned = false;
25690         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25691         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
25692         uint64_t ret_ref = (uint64_t)ret_copy;
25693         return ret_ref;
25694 }
25695
25696 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
25697         LDKRouteHintHop this_ptr_conv;
25698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25699         this_ptr_conv.is_owned = false;
25700         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25701         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
25702         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
25703 }
25704
25705 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
25706         LDKRouteHintHop this_ptr_conv;
25707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25708         this_ptr_conv.is_owned = false;
25709         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25710         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
25711         uint64_t ret_ref = (uint64_t)ret_copy;
25712         return ret_ref;
25713 }
25714
25715 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
25716         LDKRouteHintHop this_ptr_conv;
25717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25718         this_ptr_conv.is_owned = false;
25719         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
25720         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
25721         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
25722 }
25723
25724 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) {
25725         LDKPublicKey src_node_id_arg_ref;
25726         CHECK(*((uint32_t*)src_node_id_arg) == 33);
25727         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
25728         LDKRoutingFees fees_arg_conv;
25729         fees_arg_conv.inner = (void*)(fees_arg & (~1));
25730         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
25731         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
25732         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
25733         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
25734         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
25735         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
25736         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);
25737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25739         uint64_t ret_ref = (uint64_t)ret_var.inner;
25740         if (ret_var.is_owned) {
25741                 ret_ref |= 1;
25742         }
25743         return ret_ref;
25744 }
25745
25746 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
25747         LDKRouteHintHop orig_conv;
25748         orig_conv.inner = (void*)(orig & (~1));
25749         orig_conv.is_owned = false;
25750         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
25751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25753         uint64_t ret_ref = (uint64_t)ret_var.inner;
25754         if (ret_var.is_owned) {
25755                 ret_ref |= 1;
25756         }
25757         return ret_ref;
25758 }
25759
25760 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
25761         LDKRouteHintHop o_conv;
25762         o_conv.inner = (void*)(o & (~1));
25763         o_conv.is_owned = false;
25764         int64_t ret_val = RouteHintHop_hash(&o_conv);
25765         return ret_val;
25766 }
25767
25768 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
25769         LDKRouteHintHop a_conv;
25770         a_conv.inner = (void*)(a & (~1));
25771         a_conv.is_owned = false;
25772         LDKRouteHintHop b_conv;
25773         b_conv.inner = (void*)(b & (~1));
25774         b_conv.is_owned = false;
25775         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
25776         return ret_val;
25777 }
25778
25779 uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_pubkey, 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, uint32_t scorer) {
25780         LDKPublicKey our_node_pubkey_ref;
25781         CHECK(*((uint32_t*)our_node_pubkey) == 33);
25782         memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
25783         LDKNetworkGraph network_conv;
25784         network_conv.inner = (void*)(network & (~1));
25785         network_conv.is_owned = false;
25786         LDKPublicKey payee_ref;
25787         CHECK(*((uint32_t*)payee) == 33);
25788         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
25789         LDKCVec_ChannelDetailsZ first_hops_constr;
25790         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25791         if (first_hops != 0) {
25792                 first_hops_constr.datalen = *((uint32_t*)first_hops);
25793                 if (first_hops_constr.datalen > 0)
25794                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25795                 else
25796                         first_hops_constr.data = NULL;
25797                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
25798                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25799                         uint32_t first_hops_conv_16 = first_hops_vals[q];
25800                         LDKChannelDetails first_hops_conv_16_conv;
25801                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25802                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25803                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25804                 }
25805                 first_hops_ptr = &first_hops_constr;
25806         }
25807         LDKCVec_RouteHintZ last_hops_constr;
25808         last_hops_constr.datalen = *((uint32_t*)last_hops);
25809         if (last_hops_constr.datalen > 0)
25810                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25811         else
25812                 last_hops_constr.data = NULL;
25813         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
25814         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25815                 uint32_t last_hops_conv_11 = last_hops_vals[l];
25816                 LDKRouteHint last_hops_conv_11_conv;
25817                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25818                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25819                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25820                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25821         }
25822         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25823         LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
25824         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25825         *ret_conv = get_keysend_route(our_node_pubkey_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
25826         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25827         return (uint64_t)ret_conv;
25828 }
25829
25830 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_pubkey, 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, uint32_t scorer) {
25831         LDKPublicKey our_node_pubkey_ref;
25832         CHECK(*((uint32_t*)our_node_pubkey) == 33);
25833         memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
25834         LDKNetworkGraph network_conv;
25835         network_conv.inner = (void*)(network & (~1));
25836         network_conv.is_owned = false;
25837         LDKPublicKey payee_ref;
25838         CHECK(*((uint32_t*)payee) == 33);
25839         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
25840         LDKInvoiceFeatures payee_features_conv;
25841         payee_features_conv.inner = (void*)(payee_features & (~1));
25842         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
25843         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
25844         LDKCVec_ChannelDetailsZ first_hops_constr;
25845         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
25846         if (first_hops != 0) {
25847                 first_hops_constr.datalen = *((uint32_t*)first_hops);
25848                 if (first_hops_constr.datalen > 0)
25849                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25850                 else
25851                         first_hops_constr.data = NULL;
25852                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
25853                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
25854                         uint32_t first_hops_conv_16 = first_hops_vals[q];
25855                         LDKChannelDetails first_hops_conv_16_conv;
25856                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
25857                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
25858                         first_hops_constr.data[q] = first_hops_conv_16_conv;
25859                 }
25860                 first_hops_ptr = &first_hops_constr;
25861         }
25862         LDKCVec_RouteHintZ last_hops_constr;
25863         last_hops_constr.datalen = *((uint32_t*)last_hops);
25864         if (last_hops_constr.datalen > 0)
25865                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
25866         else
25867                 last_hops_constr.data = NULL;
25868         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
25869         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
25870                 uint32_t last_hops_conv_11 = last_hops_vals[l];
25871                 LDKRouteHint last_hops_conv_11_conv;
25872                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
25873                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
25874                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
25875                 last_hops_constr.data[l] = last_hops_conv_11_conv;
25876         }
25877         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25878         LDKScore* scorer_conv = (LDKScore*)(((uint64_t)scorer) & ~1);
25879         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
25880         *ret_conv = get_route(our_node_pubkey_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv, scorer_conv);
25881         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
25882         return (uint64_t)ret_conv;
25883 }
25884
25885 void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
25886         LDKScorer this_obj_conv;
25887         this_obj_conv.inner = (void*)(this_obj & (~1));
25888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25889         Scorer_free(this_obj_conv);
25890 }
25891
25892 uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(int64_t base_penalty_msat) {
25893         LDKScorer ret_var = Scorer_new(base_penalty_msat);
25894         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25895         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25896         uint64_t ret_ref = (uint64_t)ret_var.inner;
25897         if (ret_var.is_owned) {
25898                 ret_ref |= 1;
25899         }
25900         return ret_ref;
25901 }
25902
25903 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
25904         LDKScorer ret_var = Scorer_default();
25905         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25906         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25907         uint64_t ret_ref = (uint64_t)ret_var.inner;
25908         if (ret_var.is_owned) {
25909                 ret_ref |= 1;
25910         }
25911         return ret_ref;
25912 }
25913
25914 uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t this_arg) {
25915         LDKScorer this_arg_conv;
25916         this_arg_conv.inner = (void*)(this_arg & (~1));
25917         this_arg_conv.is_owned = false;
25918         LDKScore* ret_ret =MALLOC(sizeof(LDKScore), "LDKScore");
25919         *ret_ret = Scorer_as_Score(&this_arg_conv);
25920         return (uint64_t)ret_ret;
25921 }
25922
25923 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
25924         LDKFilesystemPersister this_obj_conv;
25925         this_obj_conv.inner = (void*)(this_obj & (~1));
25926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25927         FilesystemPersister_free(this_obj_conv);
25928 }
25929
25930 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
25931         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
25932         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25935         uint64_t ret_ref = (uint64_t)ret_var.inner;
25936         if (ret_var.is_owned) {
25937                 ret_ref |= 1;
25938         }
25939         return ret_ref;
25940 }
25941
25942 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
25943         LDKFilesystemPersister this_arg_conv;
25944         this_arg_conv.inner = (void*)(this_arg & (~1));
25945         this_arg_conv.is_owned = false;
25946         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25947         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25948         Str_free(ret_str);
25949         return ret_conv;
25950 }
25951
25952 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
25953         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
25954         LDKChannelManager manager_conv;
25955         manager_conv.inner = (void*)(manager & (~1));
25956         manager_conv.is_owned = false;
25957         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25958         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25959         return (uint64_t)ret_conv;
25960 }
25961
25962 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
25963         LDKFilesystemPersister this_arg_conv;
25964         this_arg_conv.inner = (void*)(this_arg & (~1));
25965         this_arg_conv.is_owned = false;
25966         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25967         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25968         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25969         return (uint64_t)ret_conv;
25970 }
25971
25972 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
25973         LDKFilesystemPersister this_arg_conv;
25974         this_arg_conv.inner = (void*)(this_arg & (~1));
25975         this_arg_conv.is_owned = false;
25976         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
25977         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
25978         return (uint64_t)ret_ret;
25979 }
25980
25981 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
25982         LDKBackgroundProcessor this_obj_conv;
25983         this_obj_conv.inner = (void*)(this_obj & (~1));
25984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25985         BackgroundProcessor_free(this_obj_conv);
25986 }
25987
25988 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
25989         if ((this_ptr & 1) != 0) return;
25990         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25991         FREE((void*)this_ptr);
25992         ChannelManagerPersister_free(this_ptr_conv);
25993 }
25994
25995 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) {
25996         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25997         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25998         LDKChainMonitor chain_monitor_conv;
25999         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
26000         chain_monitor_conv.is_owned = false;
26001         LDKChannelManager channel_manager_conv;
26002         channel_manager_conv.inner = (void*)(channel_manager & (~1));
26003         channel_manager_conv.is_owned = false;
26004         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
26005         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
26006         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
26007         LDKPeerManager peer_manager_conv;
26008         peer_manager_conv.inner = (void*)(peer_manager & (~1));
26009         peer_manager_conv.is_owned = false;
26010         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
26011         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);
26012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26014         uint64_t ret_ref = (uint64_t)ret_var.inner;
26015         if (ret_var.is_owned) {
26016                 ret_ref |= 1;
26017         }
26018         return ret_ref;
26019 }
26020
26021 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
26022         LDKBackgroundProcessor this_arg_conv;
26023         this_arg_conv.inner = (void*)(this_arg & (~1));
26024         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26025         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26026         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26027         *ret_conv = BackgroundProcessor_join(this_arg_conv);
26028         return (uint64_t)ret_conv;
26029 }
26030
26031 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
26032         LDKBackgroundProcessor this_arg_conv;
26033         this_arg_conv.inner = (void*)(this_arg & (~1));
26034         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26035         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
26036         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
26037         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
26038         return (uint64_t)ret_conv;
26039 }
26040
26041 void  __attribute__((visibility("default"))) TS_check_platform() {
26042         check_platform();
26043 }
26044
26045 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
26046         LDKInvoice this_obj_conv;
26047         this_obj_conv.inner = (void*)(this_obj & (~1));
26048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26049         Invoice_free(this_obj_conv);
26050 }
26051
26052 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
26053         LDKInvoice a_conv;
26054         a_conv.inner = (void*)(a & (~1));
26055         a_conv.is_owned = false;
26056         LDKInvoice b_conv;
26057         b_conv.inner = (void*)(b & (~1));
26058         b_conv.is_owned = false;
26059         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
26060         return ret_val;
26061 }
26062
26063 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
26064         LDKInvoice orig_conv;
26065         orig_conv.inner = (void*)(orig & (~1));
26066         orig_conv.is_owned = false;
26067         LDKInvoice ret_var = Invoice_clone(&orig_conv);
26068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26070         uint64_t ret_ref = (uint64_t)ret_var.inner;
26071         if (ret_var.is_owned) {
26072                 ret_ref |= 1;
26073         }
26074         return ret_ref;
26075 }
26076
26077 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
26078         LDKSignedRawInvoice this_obj_conv;
26079         this_obj_conv.inner = (void*)(this_obj & (~1));
26080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26081         SignedRawInvoice_free(this_obj_conv);
26082 }
26083
26084 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
26085         LDKSignedRawInvoice a_conv;
26086         a_conv.inner = (void*)(a & (~1));
26087         a_conv.is_owned = false;
26088         LDKSignedRawInvoice b_conv;
26089         b_conv.inner = (void*)(b & (~1));
26090         b_conv.is_owned = false;
26091         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
26092         return ret_val;
26093 }
26094
26095 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
26096         LDKSignedRawInvoice orig_conv;
26097         orig_conv.inner = (void*)(orig & (~1));
26098         orig_conv.is_owned = false;
26099         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
26100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26102         uint64_t ret_ref = (uint64_t)ret_var.inner;
26103         if (ret_var.is_owned) {
26104                 ret_ref |= 1;
26105         }
26106         return ret_ref;
26107 }
26108
26109 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
26110         LDKRawInvoice this_obj_conv;
26111         this_obj_conv.inner = (void*)(this_obj & (~1));
26112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26113         RawInvoice_free(this_obj_conv);
26114 }
26115
26116 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
26117         LDKRawInvoice this_ptr_conv;
26118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26119         this_ptr_conv.is_owned = false;
26120         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
26121         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26122         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26123         uint64_t ret_ref = (uint64_t)ret_var.inner;
26124         if (ret_var.is_owned) {
26125                 ret_ref |= 1;
26126         }
26127         return ret_ref;
26128 }
26129
26130 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
26131         LDKRawInvoice this_ptr_conv;
26132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26133         this_ptr_conv.is_owned = false;
26134         LDKRawDataPart val_conv;
26135         val_conv.inner = (void*)(val & (~1));
26136         val_conv.is_owned = (val & 1) || (val == 0);
26137         val_conv = RawDataPart_clone(&val_conv);
26138         RawInvoice_set_data(&this_ptr_conv, val_conv);
26139 }
26140
26141 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
26142         LDKRawInvoice a_conv;
26143         a_conv.inner = (void*)(a & (~1));
26144         a_conv.is_owned = false;
26145         LDKRawInvoice b_conv;
26146         b_conv.inner = (void*)(b & (~1));
26147         b_conv.is_owned = false;
26148         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
26149         return ret_val;
26150 }
26151
26152 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
26153         LDKRawInvoice orig_conv;
26154         orig_conv.inner = (void*)(orig & (~1));
26155         orig_conv.is_owned = false;
26156         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
26157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26159         uint64_t ret_ref = (uint64_t)ret_var.inner;
26160         if (ret_var.is_owned) {
26161                 ret_ref |= 1;
26162         }
26163         return ret_ref;
26164 }
26165
26166 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
26167         LDKRawDataPart this_obj_conv;
26168         this_obj_conv.inner = (void*)(this_obj & (~1));
26169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26170         RawDataPart_free(this_obj_conv);
26171 }
26172
26173 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
26174         LDKRawDataPart this_ptr_conv;
26175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26176         this_ptr_conv.is_owned = false;
26177         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
26178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26180         uint64_t ret_ref = (uint64_t)ret_var.inner;
26181         if (ret_var.is_owned) {
26182                 ret_ref |= 1;
26183         }
26184         return ret_ref;
26185 }
26186
26187 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
26188         LDKRawDataPart this_ptr_conv;
26189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26190         this_ptr_conv.is_owned = false;
26191         LDKPositiveTimestamp val_conv;
26192         val_conv.inner = (void*)(val & (~1));
26193         val_conv.is_owned = (val & 1) || (val == 0);
26194         val_conv = PositiveTimestamp_clone(&val_conv);
26195         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
26196 }
26197
26198 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
26199         LDKRawDataPart a_conv;
26200         a_conv.inner = (void*)(a & (~1));
26201         a_conv.is_owned = false;
26202         LDKRawDataPart b_conv;
26203         b_conv.inner = (void*)(b & (~1));
26204         b_conv.is_owned = false;
26205         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
26206         return ret_val;
26207 }
26208
26209 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
26210         LDKRawDataPart orig_conv;
26211         orig_conv.inner = (void*)(orig & (~1));
26212         orig_conv.is_owned = false;
26213         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
26214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26216         uint64_t ret_ref = (uint64_t)ret_var.inner;
26217         if (ret_var.is_owned) {
26218                 ret_ref |= 1;
26219         }
26220         return ret_ref;
26221 }
26222
26223 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
26224         LDKPositiveTimestamp this_obj_conv;
26225         this_obj_conv.inner = (void*)(this_obj & (~1));
26226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26227         PositiveTimestamp_free(this_obj_conv);
26228 }
26229
26230 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
26231         LDKPositiveTimestamp a_conv;
26232         a_conv.inner = (void*)(a & (~1));
26233         a_conv.is_owned = false;
26234         LDKPositiveTimestamp b_conv;
26235         b_conv.inner = (void*)(b & (~1));
26236         b_conv.is_owned = false;
26237         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
26238         return ret_val;
26239 }
26240
26241 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
26242         LDKPositiveTimestamp orig_conv;
26243         orig_conv.inner = (void*)(orig & (~1));
26244         orig_conv.is_owned = false;
26245         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
26246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26248         uint64_t ret_ref = (uint64_t)ret_var.inner;
26249         if (ret_var.is_owned) {
26250                 ret_ref |= 1;
26251         }
26252         return ret_ref;
26253 }
26254
26255 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
26256         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
26257         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
26258         return ret_conv;
26259 }
26260
26261 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
26262         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
26263         return ret_conv;
26264 }
26265
26266 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
26267         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
26268         return ret_conv;
26269 }
26270
26271 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
26272         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
26273         return ret_conv;
26274 }
26275
26276 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
26277         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
26278         return ret_conv;
26279 }
26280
26281 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
26282         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
26283         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
26284         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
26285         return ret_val;
26286 }
26287
26288 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
26289         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
26290         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
26291         return ret_val;
26292 }
26293
26294 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
26295         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
26296         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
26297         return ret_conv;
26298 }
26299
26300 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
26301         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
26302         return ret_conv;
26303 }
26304
26305 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
26306         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
26307         return ret_conv;
26308 }
26309
26310 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
26311         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
26312         return ret_conv;
26313 }
26314
26315 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
26316         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
26317         return ret_conv;
26318 }
26319
26320 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
26321         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
26322         return ret_conv;
26323 }
26324
26325 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
26326         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26327         int64_t ret_val = Currency_hash(o_conv);
26328         return ret_val;
26329 }
26330
26331 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
26332         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
26333         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
26334         jboolean ret_val = Currency_eq(a_conv, b_conv);
26335         return ret_val;
26336 }
26337
26338 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
26339         LDKSha256 this_obj_conv;
26340         this_obj_conv.inner = (void*)(this_obj & (~1));
26341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26342         Sha256_free(this_obj_conv);
26343 }
26344
26345 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
26346         LDKSha256 orig_conv;
26347         orig_conv.inner = (void*)(orig & (~1));
26348         orig_conv.is_owned = false;
26349         LDKSha256 ret_var = Sha256_clone(&orig_conv);
26350         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26351         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26352         uint64_t ret_ref = (uint64_t)ret_var.inner;
26353         if (ret_var.is_owned) {
26354                 ret_ref |= 1;
26355         }
26356         return ret_ref;
26357 }
26358
26359 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
26360         LDKSha256 o_conv;
26361         o_conv.inner = (void*)(o & (~1));
26362         o_conv.is_owned = false;
26363         int64_t ret_val = Sha256_hash(&o_conv);
26364         return ret_val;
26365 }
26366
26367 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
26368         LDKSha256 a_conv;
26369         a_conv.inner = (void*)(a & (~1));
26370         a_conv.is_owned = false;
26371         LDKSha256 b_conv;
26372         b_conv.inner = (void*)(b & (~1));
26373         b_conv.is_owned = false;
26374         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
26375         return ret_val;
26376 }
26377
26378 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
26379         LDKDescription this_obj_conv;
26380         this_obj_conv.inner = (void*)(this_obj & (~1));
26381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26382         Description_free(this_obj_conv);
26383 }
26384
26385 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
26386         LDKDescription orig_conv;
26387         orig_conv.inner = (void*)(orig & (~1));
26388         orig_conv.is_owned = false;
26389         LDKDescription ret_var = Description_clone(&orig_conv);
26390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26392         uint64_t ret_ref = (uint64_t)ret_var.inner;
26393         if (ret_var.is_owned) {
26394                 ret_ref |= 1;
26395         }
26396         return ret_ref;
26397 }
26398
26399 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
26400         LDKDescription o_conv;
26401         o_conv.inner = (void*)(o & (~1));
26402         o_conv.is_owned = false;
26403         int64_t ret_val = Description_hash(&o_conv);
26404         return ret_val;
26405 }
26406
26407 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
26408         LDKDescription a_conv;
26409         a_conv.inner = (void*)(a & (~1));
26410         a_conv.is_owned = false;
26411         LDKDescription b_conv;
26412         b_conv.inner = (void*)(b & (~1));
26413         b_conv.is_owned = false;
26414         jboolean ret_val = Description_eq(&a_conv, &b_conv);
26415         return ret_val;
26416 }
26417
26418 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
26419         LDKPayeePubKey this_obj_conv;
26420         this_obj_conv.inner = (void*)(this_obj & (~1));
26421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26422         PayeePubKey_free(this_obj_conv);
26423 }
26424
26425 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
26426         LDKPayeePubKey orig_conv;
26427         orig_conv.inner = (void*)(orig & (~1));
26428         orig_conv.is_owned = false;
26429         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
26430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26432         uint64_t ret_ref = (uint64_t)ret_var.inner;
26433         if (ret_var.is_owned) {
26434                 ret_ref |= 1;
26435         }
26436         return ret_ref;
26437 }
26438
26439 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
26440         LDKPayeePubKey o_conv;
26441         o_conv.inner = (void*)(o & (~1));
26442         o_conv.is_owned = false;
26443         int64_t ret_val = PayeePubKey_hash(&o_conv);
26444         return ret_val;
26445 }
26446
26447 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
26448         LDKPayeePubKey a_conv;
26449         a_conv.inner = (void*)(a & (~1));
26450         a_conv.is_owned = false;
26451         LDKPayeePubKey b_conv;
26452         b_conv.inner = (void*)(b & (~1));
26453         b_conv.is_owned = false;
26454         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
26455         return ret_val;
26456 }
26457
26458 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
26459         LDKExpiryTime this_obj_conv;
26460         this_obj_conv.inner = (void*)(this_obj & (~1));
26461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26462         ExpiryTime_free(this_obj_conv);
26463 }
26464
26465 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
26466         LDKExpiryTime orig_conv;
26467         orig_conv.inner = (void*)(orig & (~1));
26468         orig_conv.is_owned = false;
26469         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
26470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26472         uint64_t ret_ref = (uint64_t)ret_var.inner;
26473         if (ret_var.is_owned) {
26474                 ret_ref |= 1;
26475         }
26476         return ret_ref;
26477 }
26478
26479 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
26480         LDKExpiryTime o_conv;
26481         o_conv.inner = (void*)(o & (~1));
26482         o_conv.is_owned = false;
26483         int64_t ret_val = ExpiryTime_hash(&o_conv);
26484         return ret_val;
26485 }
26486
26487 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
26488         LDKExpiryTime a_conv;
26489         a_conv.inner = (void*)(a & (~1));
26490         a_conv.is_owned = false;
26491         LDKExpiryTime b_conv;
26492         b_conv.inner = (void*)(b & (~1));
26493         b_conv.is_owned = false;
26494         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
26495         return ret_val;
26496 }
26497
26498 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
26499         LDKMinFinalCltvExpiry this_obj_conv;
26500         this_obj_conv.inner = (void*)(this_obj & (~1));
26501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26502         MinFinalCltvExpiry_free(this_obj_conv);
26503 }
26504
26505 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
26506         LDKMinFinalCltvExpiry orig_conv;
26507         orig_conv.inner = (void*)(orig & (~1));
26508         orig_conv.is_owned = false;
26509         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
26510         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26511         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26512         uint64_t ret_ref = (uint64_t)ret_var.inner;
26513         if (ret_var.is_owned) {
26514                 ret_ref |= 1;
26515         }
26516         return ret_ref;
26517 }
26518
26519 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
26520         LDKMinFinalCltvExpiry o_conv;
26521         o_conv.inner = (void*)(o & (~1));
26522         o_conv.is_owned = false;
26523         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
26524         return ret_val;
26525 }
26526
26527 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
26528         LDKMinFinalCltvExpiry a_conv;
26529         a_conv.inner = (void*)(a & (~1));
26530         a_conv.is_owned = false;
26531         LDKMinFinalCltvExpiry b_conv;
26532         b_conv.inner = (void*)(b & (~1));
26533         b_conv.is_owned = false;
26534         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
26535         return ret_val;
26536 }
26537
26538 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
26539         if ((this_ptr & 1) != 0) return;
26540         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
26541         FREE((void*)this_ptr);
26542         Fallback_free(this_ptr_conv);
26543 }
26544
26545 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
26546         LDKFallback* orig_conv = (LDKFallback*)orig;
26547         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26548         *ret_copy = Fallback_clone(orig_conv);
26549         uint64_t ret_ref = (uint64_t)ret_copy;
26550         return ret_ref;
26551 }
26552
26553 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
26554         
26555         LDKCVec_u8Z program_ref;
26556         program_ref.datalen = *((uint32_t*)program);
26557         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
26558         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
26559         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26560         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
26561         uint64_t ret_ref = (uint64_t)ret_copy;
26562         return ret_ref;
26563 }
26564
26565 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
26566         LDKTwentyBytes a_ref;
26567         CHECK(*((uint32_t*)a) == 20);
26568         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
26569         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26570         *ret_copy = Fallback_pub_key_hash(a_ref);
26571         uint64_t ret_ref = (uint64_t)ret_copy;
26572         return ret_ref;
26573 }
26574
26575 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
26576         LDKTwentyBytes a_ref;
26577         CHECK(*((uint32_t*)a) == 20);
26578         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
26579         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26580         *ret_copy = Fallback_script_hash(a_ref);
26581         uint64_t ret_ref = (uint64_t)ret_copy;
26582         return ret_ref;
26583 }
26584
26585 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
26586         LDKFallback* o_conv = (LDKFallback*)o;
26587         int64_t ret_val = Fallback_hash(o_conv);
26588         return ret_val;
26589 }
26590
26591 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
26592         LDKFallback* a_conv = (LDKFallback*)a;
26593         LDKFallback* b_conv = (LDKFallback*)b;
26594         jboolean ret_val = Fallback_eq(a_conv, b_conv);
26595         return ret_val;
26596 }
26597
26598 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
26599         LDKInvoiceSignature this_obj_conv;
26600         this_obj_conv.inner = (void*)(this_obj & (~1));
26601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26602         InvoiceSignature_free(this_obj_conv);
26603 }
26604
26605 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
26606         LDKInvoiceSignature orig_conv;
26607         orig_conv.inner = (void*)(orig & (~1));
26608         orig_conv.is_owned = false;
26609         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
26610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26612         uint64_t ret_ref = (uint64_t)ret_var.inner;
26613         if (ret_var.is_owned) {
26614                 ret_ref |= 1;
26615         }
26616         return ret_ref;
26617 }
26618
26619 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
26620         LDKInvoiceSignature a_conv;
26621         a_conv.inner = (void*)(a & (~1));
26622         a_conv.is_owned = false;
26623         LDKInvoiceSignature b_conv;
26624         b_conv.inner = (void*)(b & (~1));
26625         b_conv.is_owned = false;
26626         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
26627         return ret_val;
26628 }
26629
26630 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
26631         LDKPrivateRoute this_obj_conv;
26632         this_obj_conv.inner = (void*)(this_obj & (~1));
26633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26634         PrivateRoute_free(this_obj_conv);
26635 }
26636
26637 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
26638         LDKPrivateRoute orig_conv;
26639         orig_conv.inner = (void*)(orig & (~1));
26640         orig_conv.is_owned = false;
26641         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
26642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26644         uint64_t ret_ref = (uint64_t)ret_var.inner;
26645         if (ret_var.is_owned) {
26646                 ret_ref |= 1;
26647         }
26648         return ret_ref;
26649 }
26650
26651 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
26652         LDKPrivateRoute o_conv;
26653         o_conv.inner = (void*)(o & (~1));
26654         o_conv.is_owned = false;
26655         int64_t ret_val = PrivateRoute_hash(&o_conv);
26656         return ret_val;
26657 }
26658
26659 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
26660         LDKPrivateRoute a_conv;
26661         a_conv.inner = (void*)(a & (~1));
26662         a_conv.is_owned = false;
26663         LDKPrivateRoute b_conv;
26664         b_conv.inner = (void*)(b & (~1));
26665         b_conv.is_owned = false;
26666         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
26667         return ret_val;
26668 }
26669
26670 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
26671         LDKSignedRawInvoice this_arg_conv;
26672         this_arg_conv.inner = (void*)(this_arg & (~1));
26673         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26674         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
26675         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
26676         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
26677         return ((uint64_t)ret_conv);
26678 }
26679
26680 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
26681         LDKSignedRawInvoice this_arg_conv;
26682         this_arg_conv.inner = (void*)(this_arg & (~1));
26683         this_arg_conv.is_owned = false;
26684         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
26685         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26686         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26687         uint64_t ret_ref = (uint64_t)ret_var.inner;
26688         if (ret_var.is_owned) {
26689                 ret_ref |= 1;
26690         }
26691         return ret_ref;
26692 }
26693
26694 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
26695         LDKSignedRawInvoice this_arg_conv;
26696         this_arg_conv.inner = (void*)(this_arg & (~1));
26697         this_arg_conv.is_owned = false;
26698         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26699         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
26700         return ret_arr;
26701 }
26702
26703 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
26704         LDKSignedRawInvoice this_arg_conv;
26705         this_arg_conv.inner = (void*)(this_arg & (~1));
26706         this_arg_conv.is_owned = false;
26707         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
26708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26710         uint64_t ret_ref = (uint64_t)ret_var.inner;
26711         if (ret_var.is_owned) {
26712                 ret_ref |= 1;
26713         }
26714         return ret_ref;
26715 }
26716
26717 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
26718         LDKSignedRawInvoice this_arg_conv;
26719         this_arg_conv.inner = (void*)(this_arg & (~1));
26720         this_arg_conv.is_owned = false;
26721         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
26722         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
26723         return (uint64_t)ret_conv;
26724 }
26725
26726 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
26727         LDKSignedRawInvoice this_arg_conv;
26728         this_arg_conv.inner = (void*)(this_arg & (~1));
26729         this_arg_conv.is_owned = false;
26730         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
26731         return ret_val;
26732 }
26733
26734 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
26735         LDKRawInvoice this_arg_conv;
26736         this_arg_conv.inner = (void*)(this_arg & (~1));
26737         this_arg_conv.is_owned = false;
26738         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26739         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
26740         return ret_arr;
26741 }
26742
26743 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
26744         LDKRawInvoice this_arg_conv;
26745         this_arg_conv.inner = (void*)(this_arg & (~1));
26746         this_arg_conv.is_owned = false;
26747         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
26748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26750         uint64_t ret_ref = (uint64_t)ret_var.inner;
26751         if (ret_var.is_owned) {
26752                 ret_ref |= 1;
26753         }
26754         return ret_ref;
26755 }
26756
26757 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
26758         LDKRawInvoice this_arg_conv;
26759         this_arg_conv.inner = (void*)(this_arg & (~1));
26760         this_arg_conv.is_owned = false;
26761         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
26762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26764         uint64_t ret_ref = (uint64_t)ret_var.inner;
26765         if (ret_var.is_owned) {
26766                 ret_ref |= 1;
26767         }
26768         return ret_ref;
26769 }
26770
26771 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
26772         LDKRawInvoice this_arg_conv;
26773         this_arg_conv.inner = (void*)(this_arg & (~1));
26774         this_arg_conv.is_owned = false;
26775         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
26776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26778         uint64_t ret_ref = (uint64_t)ret_var.inner;
26779         if (ret_var.is_owned) {
26780                 ret_ref |= 1;
26781         }
26782         return ret_ref;
26783 }
26784
26785 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
26786         LDKRawInvoice this_arg_conv;
26787         this_arg_conv.inner = (void*)(this_arg & (~1));
26788         this_arg_conv.is_owned = false;
26789         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
26790         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26791         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26792         uint64_t ret_ref = (uint64_t)ret_var.inner;
26793         if (ret_var.is_owned) {
26794                 ret_ref |= 1;
26795         }
26796         return ret_ref;
26797 }
26798
26799 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
26800         LDKRawInvoice this_arg_conv;
26801         this_arg_conv.inner = (void*)(this_arg & (~1));
26802         this_arg_conv.is_owned = false;
26803         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
26804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26806         uint64_t ret_ref = (uint64_t)ret_var.inner;
26807         if (ret_var.is_owned) {
26808                 ret_ref |= 1;
26809         }
26810         return ret_ref;
26811 }
26812
26813 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
26814         LDKRawInvoice this_arg_conv;
26815         this_arg_conv.inner = (void*)(this_arg & (~1));
26816         this_arg_conv.is_owned = false;
26817         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
26818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26820         uint64_t ret_ref = (uint64_t)ret_var.inner;
26821         if (ret_var.is_owned) {
26822                 ret_ref |= 1;
26823         }
26824         return ret_ref;
26825 }
26826
26827 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
26828         LDKRawInvoice this_arg_conv;
26829         this_arg_conv.inner = (void*)(this_arg & (~1));
26830         this_arg_conv.is_owned = false;
26831         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26832         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
26833         return ret_arr;
26834 }
26835
26836 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
26837         LDKRawInvoice this_arg_conv;
26838         this_arg_conv.inner = (void*)(this_arg & (~1));
26839         this_arg_conv.is_owned = false;
26840         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
26841         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26842         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26843         uint64_t ret_ref = (uint64_t)ret_var.inner;
26844         if (ret_var.is_owned) {
26845                 ret_ref |= 1;
26846         }
26847         return ret_ref;
26848 }
26849
26850 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
26851         LDKRawInvoice this_arg_conv;
26852         this_arg_conv.inner = (void*)(this_arg & (~1));
26853         this_arg_conv.is_owned = false;
26854         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26855         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26856         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26857         for (size_t o = 0; o < ret_var.datalen; o++) {
26858                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26859                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26860                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26861                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26862                 if (ret_conv_14_var.is_owned) {
26863                         ret_conv_14_ref |= 1;
26864                 }
26865                 ret_arr_ptr[o] = ret_conv_14_ref;
26866         }
26867         FREE(ret_var.data);
26868         return ret_arr;
26869 }
26870
26871 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
26872         LDKRawInvoice this_arg_conv;
26873         this_arg_conv.inner = (void*)(this_arg & (~1));
26874         this_arg_conv.is_owned = false;
26875         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26876         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26877         uint64_t ret_ref = (uint64_t)ret_copy;
26878         return ret_ref;
26879 }
26880
26881 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
26882         LDKRawInvoice this_arg_conv;
26883         this_arg_conv.inner = (void*)(this_arg & (~1));
26884         this_arg_conv.is_owned = false;
26885         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
26886         return ret_conv;
26887 }
26888
26889 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
26890         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26891         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26892         return (uint64_t)ret_conv;
26893 }
26894
26895 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
26896         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26897         *ret_conv = PositiveTimestamp_from_system_time(time);
26898         return (uint64_t)ret_conv;
26899 }
26900
26901 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
26902         LDKPositiveTimestamp this_arg_conv;
26903         this_arg_conv.inner = (void*)(this_arg & (~1));
26904         this_arg_conv.is_owned = false;
26905         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26906         return ret_val;
26907 }
26908
26909 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
26910         LDKPositiveTimestamp this_arg_conv;
26911         this_arg_conv.inner = (void*)(this_arg & (~1));
26912         this_arg_conv.is_owned = false;
26913         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26914         return ret_val;
26915 }
26916
26917 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
26918         LDKInvoice this_arg_conv;
26919         this_arg_conv.inner = (void*)(this_arg & (~1));
26920         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26921         this_arg_conv = Invoice_clone(&this_arg_conv);
26922         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26925         uint64_t ret_ref = (uint64_t)ret_var.inner;
26926         if (ret_var.is_owned) {
26927                 ret_ref |= 1;
26928         }
26929         return ret_ref;
26930 }
26931
26932 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
26933         LDKInvoice this_arg_conv;
26934         this_arg_conv.inner = (void*)(this_arg & (~1));
26935         this_arg_conv.is_owned = false;
26936         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26937         *ret_conv = Invoice_check_signature(&this_arg_conv);
26938         return (uint64_t)ret_conv;
26939 }
26940
26941 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
26942         LDKSignedRawInvoice signed_invoice_conv;
26943         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26944         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26945         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26946         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26947         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26948         return (uint64_t)ret_conv;
26949 }
26950
26951 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
26952         LDKInvoice this_arg_conv;
26953         this_arg_conv.inner = (void*)(this_arg & (~1));
26954         this_arg_conv.is_owned = false;
26955         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26956         return ret_val;
26957 }
26958
26959 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
26960         LDKInvoice this_arg_conv;
26961         this_arg_conv.inner = (void*)(this_arg & (~1));
26962         this_arg_conv.is_owned = false;
26963         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26964         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
26965         return ret_arr;
26966 }
26967
26968 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
26969         LDKInvoice this_arg_conv;
26970         this_arg_conv.inner = (void*)(this_arg & (~1));
26971         this_arg_conv.is_owned = false;
26972         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26973         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
26974         return ret_arr;
26975 }
26976
26977 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
26978         LDKInvoice this_arg_conv;
26979         this_arg_conv.inner = (void*)(this_arg & (~1));
26980         this_arg_conv.is_owned = false;
26981         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26982         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
26983         return ret_arr;
26984 }
26985
26986 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
26987         LDKInvoice this_arg_conv;
26988         this_arg_conv.inner = (void*)(this_arg & (~1));
26989         this_arg_conv.is_owned = false;
26990         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26991         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26992         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26993         uint64_t ret_ref = (uint64_t)ret_var.inner;
26994         if (ret_var.is_owned) {
26995                 ret_ref |= 1;
26996         }
26997         return ret_ref;
26998 }
26999
27000 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
27001         LDKInvoice this_arg_conv;
27002         this_arg_conv.inner = (void*)(this_arg & (~1));
27003         this_arg_conv.is_owned = false;
27004         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
27005         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
27006         return ret_arr;
27007 }
27008
27009 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
27010         LDKInvoice this_arg_conv;
27011         this_arg_conv.inner = (void*)(this_arg & (~1));
27012         this_arg_conv.is_owned = false;
27013         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
27014         return ret_val;
27015 }
27016
27017 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
27018         LDKInvoice this_arg_conv;
27019         this_arg_conv.inner = (void*)(this_arg & (~1));
27020         this_arg_conv.is_owned = false;
27021         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
27022         return ret_val;
27023 }
27024
27025 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
27026         LDKInvoice this_arg_conv;
27027         this_arg_conv.inner = (void*)(this_arg & (~1));
27028         this_arg_conv.is_owned = false;
27029         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
27030         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27031         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27032         for (size_t o = 0; o < ret_var.datalen; o++) {
27033                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
27034                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27035                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27036                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
27037                 if (ret_conv_14_var.is_owned) {
27038                         ret_conv_14_ref |= 1;
27039                 }
27040                 ret_arr_ptr[o] = ret_conv_14_ref;
27041         }
27042         FREE(ret_var.data);
27043         return ret_arr;
27044 }
27045
27046 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
27047         LDKInvoice this_arg_conv;
27048         this_arg_conv.inner = (void*)(this_arg & (~1));
27049         this_arg_conv.is_owned = false;
27050         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
27051         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27052         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27053         for (size_t l = 0; l < ret_var.datalen; l++) {
27054                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
27055                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27056                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27057                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
27058                 if (ret_conv_11_var.is_owned) {
27059                         ret_conv_11_ref |= 1;
27060                 }
27061                 ret_arr_ptr[l] = ret_conv_11_ref;
27062         }
27063         FREE(ret_var.data);
27064         return ret_arr;
27065 }
27066
27067 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
27068         LDKInvoice this_arg_conv;
27069         this_arg_conv.inner = (void*)(this_arg & (~1));
27070         this_arg_conv.is_owned = false;
27071         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
27072         return ret_conv;
27073 }
27074
27075 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
27076         LDKInvoice this_arg_conv;
27077         this_arg_conv.inner = (void*)(this_arg & (~1));
27078         this_arg_conv.is_owned = false;
27079         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27080         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
27081         uint64_t ret_ref = (uint64_t)ret_copy;
27082         return ret_ref;
27083 }
27084
27085 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
27086         LDKStr description_conv = str_ref_to_owned_c(description);
27087         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
27088         *ret_conv = Description_new(description_conv);
27089         return (uint64_t)ret_conv;
27090 }
27091
27092 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
27093         LDKDescription this_arg_conv;
27094         this_arg_conv.inner = (void*)(this_arg & (~1));
27095         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27096         this_arg_conv = Description_clone(&this_arg_conv);
27097         LDKStr ret_str = Description_into_inner(this_arg_conv);
27098         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27099         Str_free(ret_str);
27100         return ret_conv;
27101 }
27102
27103 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
27104         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27105         *ret_conv = ExpiryTime_from_seconds(seconds);
27106         return (uint64_t)ret_conv;
27107 }
27108
27109 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
27110         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
27111         *ret_conv = ExpiryTime_from_duration(duration);
27112         return (uint64_t)ret_conv;
27113 }
27114
27115 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
27116         LDKExpiryTime this_arg_conv;
27117         this_arg_conv.inner = (void*)(this_arg & (~1));
27118         this_arg_conv.is_owned = false;
27119         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
27120         return ret_val;
27121 }
27122
27123 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
27124         LDKExpiryTime this_arg_conv;
27125         this_arg_conv.inner = (void*)(this_arg & (~1));
27126         this_arg_conv.is_owned = false;
27127         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
27128         return ret_val;
27129 }
27130
27131 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
27132         LDKRouteHint hops_conv;
27133         hops_conv.inner = (void*)(hops & (~1));
27134         hops_conv.is_owned = (hops & 1) || (hops == 0);
27135         hops_conv = RouteHint_clone(&hops_conv);
27136         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
27137         *ret_conv = PrivateRoute_new(hops_conv);
27138         return (uint64_t)ret_conv;
27139 }
27140
27141 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
27142         LDKPrivateRoute this_arg_conv;
27143         this_arg_conv.inner = (void*)(this_arg & (~1));
27144         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
27145         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
27146         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
27147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27149         uint64_t ret_ref = (uint64_t)ret_var.inner;
27150         if (ret_var.is_owned) {
27151                 ret_ref |= 1;
27152         }
27153         return ret_ref;
27154 }
27155
27156 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
27157         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
27158         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
27159         return ret_conv;
27160 }
27161
27162 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
27163         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
27164         return ret_conv;
27165 }
27166
27167 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
27168         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
27169         return ret_conv;
27170 }
27171
27172 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
27173         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
27174         return ret_conv;
27175 }
27176
27177 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
27178         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
27179         return ret_conv;
27180 }
27181
27182 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
27183         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
27184         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
27185         jboolean ret_val = CreationError_eq(a_conv, b_conv);
27186         return ret_val;
27187 }
27188
27189 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
27190         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
27191         LDKStr ret_str = CreationError_to_str(o_conv);
27192         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27193         Str_free(ret_str);
27194         return ret_conv;
27195 }
27196
27197 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
27198         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
27199         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
27200         return ret_conv;
27201 }
27202
27203 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
27204         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
27205         return ret_conv;
27206 }
27207
27208 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
27209         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
27210         return ret_conv;
27211 }
27212
27213 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
27214         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
27215         return ret_conv;
27216 }
27217
27218 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
27219         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
27220         return ret_conv;
27221 }
27222
27223 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
27224         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
27225         return ret_conv;
27226 }
27227
27228 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
27229         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
27230         return ret_conv;
27231 }
27232
27233 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
27234         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
27235         return ret_conv;
27236 }
27237
27238 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
27239         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
27240         return ret_conv;
27241 }
27242
27243 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
27244         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
27245         return ret_conv;
27246 }
27247
27248 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
27249         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
27250         return ret_conv;
27251 }
27252
27253 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
27254         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
27255         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
27256         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
27257         return ret_val;
27258 }
27259
27260 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
27261         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
27262         LDKStr ret_str = SemanticError_to_str(o_conv);
27263         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27264         Str_free(ret_str);
27265         return ret_conv;
27266 }
27267
27268 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
27269         if ((this_ptr & 1) != 0) return;
27270         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
27271         FREE((void*)this_ptr);
27272         SignOrCreationError_free(this_ptr_conv);
27273 }
27274
27275 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
27276         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
27277         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27278         *ret_copy = SignOrCreationError_clone(orig_conv);
27279         uint64_t ret_ref = (uint64_t)ret_copy;
27280         return ret_ref;
27281 }
27282
27283 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
27284         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27285         *ret_copy = SignOrCreationError_sign_error();
27286         uint64_t ret_ref = (uint64_t)ret_copy;
27287         return ret_ref;
27288 }
27289
27290 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
27291         LDKCreationError a_conv = LDKCreationError_from_js(a);
27292         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
27293         *ret_copy = SignOrCreationError_creation_error(a_conv);
27294         uint64_t ret_ref = (uint64_t)ret_copy;
27295         return ret_ref;
27296 }
27297
27298 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
27299         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
27300         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
27301         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
27302         return ret_val;
27303 }
27304
27305 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
27306         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
27307         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
27308         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27309         Str_free(ret_str);
27310         return ret_conv;
27311 }
27312
27313 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) {
27314         LDKChannelManager channelmanager_conv;
27315         channelmanager_conv.inner = (void*)(channelmanager & (~1));
27316         channelmanager_conv.is_owned = false;
27317         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
27318         LDKCurrency network_conv = LDKCurrency_from_js(network);
27319         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
27320         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
27321         LDKStr description_conv = str_ref_to_owned_c(description);
27322         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
27323         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
27324         return (uint64_t)ret_conv;
27325 }
27326
27327 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
27328         LDKStr s_conv = str_ref_to_owned_c(s);
27329         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
27330         *ret_conv = SiPrefix_from_str(s_conv);
27331         return (uint64_t)ret_conv;
27332 }
27333
27334 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
27335         LDKStr s_conv = str_ref_to_owned_c(s);
27336         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
27337         *ret_conv = Invoice_from_str(s_conv);
27338         return (uint64_t)ret_conv;
27339 }
27340
27341 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
27342         LDKStr s_conv = str_ref_to_owned_c(s);
27343         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
27344         *ret_conv = SignedRawInvoice_from_str(s_conv);
27345         return (uint64_t)ret_conv;
27346 }
27347
27348 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
27349         LDKInvoice o_conv;
27350         o_conv.inner = (void*)(o & (~1));
27351         o_conv.is_owned = false;
27352         LDKStr ret_str = Invoice_to_str(&o_conv);
27353         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27354         Str_free(ret_str);
27355         return ret_conv;
27356 }
27357
27358 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
27359         LDKSignedRawInvoice o_conv;
27360         o_conv.inner = (void*)(o & (~1));
27361         o_conv.is_owned = false;
27362         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
27363         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27364         Str_free(ret_str);
27365         return ret_conv;
27366 }
27367
27368 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
27369         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
27370         LDKStr ret_str = Currency_to_str(o_conv);
27371         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27372         Str_free(ret_str);
27373         return ret_conv;
27374 }
27375
27376 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
27377         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
27378         LDKStr ret_str = SiPrefix_to_str(o_conv);
27379         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27380         Str_free(ret_str);
27381         return ret_conv;
27382 }
27383