Update java bindings with new generator and new upstream code
[ldk-java] / ts / bindings.c
1 #include <rust_types.h>
2 #include "js-wasm.h"
3 #include <stdatomic.h>
4 #include <lightning.h>
5
6 // These should be provided...somehow...
7 void *memset(void *s, int c, size_t n);
8 void *memcpy(void *dest, const void *src, size_t n);
9 int memcmp(const void *s1, const void *s2, size_t n);
10
11 void __attribute__((noreturn)) abort(void);
12 static inline void assert(bool expression) {
13         if (!expression) { abort(); }
14 }
15
16 void *malloc(size_t size);
17 void free(void *ptr);
18
19 #define MALLOC(a, _) malloc(a)
20 #define FREE(p) if ((long)(p) > 1024) { free(p); }
21 #define DO_ASSERT(a) (void)(a)
22 #define CHECK(a)
23
24 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
25 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
27 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
28
29 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
30
31 typedef uint32_t int64_tArray;
32 typedef uint32_t int8_tArray;
33 typedef uint32_t uint32_tArray;
34 typedef uint32_t ptrArray;
35 typedef uint32_t jstring;
36
37 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
38         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
39         elems[0] = arr_len;
40         return (uint32_t)elems;
41 }
42
43 jstring str_ref_to_ts(const char* chars, size_t len) {
44         char* err_buf = MALLOC(len + 4, "str conv buf");
45         *((uint32_t*)err_buf) = len;
46         memcpy(err_buf + 4, chars, len);
47         return (uint32_t) err_buf;
48 }
49
50 typedef bool jboolean;
51
52 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
53         return (uint32_t)MALLOC(size, "JS-Called malloc");
54 }
55 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
56         FREE((void*)ptr);
57 }
58 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
59 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
60         switch (ord) {
61                 case 0: return LDKAccessError_UnknownChain;
62                 case 1: return LDKAccessError_UnknownTx;
63         }
64         abort();
65 }
66 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
67         switch (val) {
68                 case LDKAccessError_UnknownChain: return 0;
69                 case LDKAccessError_UnknownTx: return 1;
70                 default: abort();
71         }
72 }
73 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
74         switch (ord) {
75                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
76                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
77         }
78         abort();
79 }
80 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
81         switch (val) {
82                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
83                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
84                 default: abort();
85         }
86 }
87 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
88         switch (ord) {
89                 case 0: return LDKConfirmationTarget_Background;
90                 case 1: return LDKConfirmationTarget_Normal;
91                 case 2: return LDKConfirmationTarget_HighPriority;
92         }
93         abort();
94 }
95 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
96         switch (val) {
97                 case LDKConfirmationTarget_Background: return 0;
98                 case LDKConfirmationTarget_Normal: return 1;
99                 case LDKConfirmationTarget_HighPriority: return 2;
100                 default: abort();
101         }
102 }
103 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
104         switch (ord) {
105                 case 0: return LDKLevel_Off;
106                 case 1: return LDKLevel_Error;
107                 case 2: return LDKLevel_Warn;
108                 case 3: return LDKLevel_Info;
109                 case 4: return LDKLevel_Debug;
110                 case 5: return LDKLevel_Trace;
111         }
112         abort();
113 }
114 static inline int32_t LDKLevel_to_js(LDKLevel val) {
115         switch (val) {
116                 case LDKLevel_Off: return 0;
117                 case LDKLevel_Error: return 1;
118                 case LDKLevel_Warn: return 2;
119                 case LDKLevel_Info: return 3;
120                 case LDKLevel_Debug: return 4;
121                 case LDKLevel_Trace: return 5;
122                 default: abort();
123         }
124 }
125 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKNetwork_Bitcoin;
128                 case 1: return LDKNetwork_Testnet;
129                 case 2: return LDKNetwork_Regtest;
130                 case 3: return LDKNetwork_Signet;
131         }
132         abort();
133 }
134 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
135         switch (val) {
136                 case LDKNetwork_Bitcoin: return 0;
137                 case LDKNetwork_Testnet: return 1;
138                 case LDKNetwork_Regtest: return 2;
139                 case LDKNetwork_Signet: return 3;
140                 default: abort();
141         }
142 }
143 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
144         switch (ord) {
145                 case 0: return LDKSecp256k1Error_IncorrectSignature;
146                 case 1: return LDKSecp256k1Error_InvalidMessage;
147                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
148                 case 3: return LDKSecp256k1Error_InvalidSignature;
149                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
150                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
151                 case 6: return LDKSecp256k1Error_InvalidTweak;
152                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
153                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
154         }
155         abort();
156 }
157 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
158         switch (val) {
159                 case LDKSecp256k1Error_IncorrectSignature: return 0;
160                 case LDKSecp256k1Error_InvalidMessage: return 1;
161                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
162                 case LDKSecp256k1Error_InvalidSignature: return 3;
163                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
164                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
165                 case LDKSecp256k1Error_InvalidTweak: return 6;
166                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
167                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
168                 default: abort();
169         }
170 }
171 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
172         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
173         ret->datalen = *((uint32_t*)elems);
174         if (ret->datalen == 0) {
175                 ret->data = NULL;
176         } else {
177                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
178                 int8_t *java_elems = (int8_t*)(elems + 4);
179                 for (size_t i = 0; i < ret->datalen; i++) {
180                         ret->data[i] = java_elems[i];
181                 }
182         }
183         return (long)ret;
184 }
185 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
186         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
187         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
188         return ret;
189 }
190 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
191         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
192 }
193 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
194         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
195         CHECK(val->result_ok);
196         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
197         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
198         return res_arr;
199 }
200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
201         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
202         CHECK(!val->result_ok);
203         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
204         return err_conv;
205 }
206 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
207         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
208 }
209 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
210         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
211         CHECK(val->result_ok);
212         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
213         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
214         return res_arr;
215 }
216 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
217         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
218         CHECK(!val->result_ok);
219         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
220         return err_conv;
221 }
222 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
223         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
224 }
225 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
226         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
227         CHECK(val->result_ok);
228         LDKTxCreationKeys res_var = (*val->contents.result);
229         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
230         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
231         long res_ref = (long)res_var.inner & ~1;
232         return res_ref;
233 }
234 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
235         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
236         CHECK(!val->result_ok);
237         LDKDecodeError err_var = (*val->contents.err);
238         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
239         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
240         long err_ref = (long)err_var.inner & ~1;
241         return err_ref;
242 }
243 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
244         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
245 }
246 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
247         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
248         CHECK(val->result_ok);
249         LDKChannelPublicKeys res_var = (*val->contents.result);
250         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
251         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
252         long res_ref = (long)res_var.inner & ~1;
253         return res_ref;
254 }
255 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
256         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
257         CHECK(!val->result_ok);
258         LDKDecodeError err_var = (*val->contents.err);
259         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
260         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
261         long err_ref = (long)err_var.inner & ~1;
262         return err_ref;
263 }
264 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
265         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
266 }
267 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
268         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
269         CHECK(val->result_ok);
270         LDKTxCreationKeys res_var = (*val->contents.result);
271         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
272         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
273         long res_ref = (long)res_var.inner & ~1;
274         return res_ref;
275 }
276 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
277         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
278         CHECK(!val->result_ok);
279         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
280         return err_conv;
281 }
282 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
283         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
284 }
285 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
286         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
287         CHECK(val->result_ok);
288         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
289         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
290         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
291         long res_ref = (long)res_var.inner & ~1;
292         return res_ref;
293 }
294 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
295         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
296         CHECK(!val->result_ok);
297         LDKDecodeError err_var = (*val->contents.err);
298         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
299         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
300         long err_ref = (long)err_var.inner & ~1;
301         return err_ref;
302 }
303 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
304         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
305 }
306 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
307         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
308         CHECK(val->result_ok);
309         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
310         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
311         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
312         long res_ref = (long)res_var.inner & ~1;
313         return res_ref;
314 }
315 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
316         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
317         CHECK(!val->result_ok);
318         LDKDecodeError err_var = (*val->contents.err);
319         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
320         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
321         long err_ref = (long)err_var.inner & ~1;
322         return err_ref;
323 }
324 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
325         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
326 }
327 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
328         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
329         CHECK(val->result_ok);
330         LDKChannelTransactionParameters res_var = (*val->contents.result);
331         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
332         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
333         long res_ref = (long)res_var.inner & ~1;
334         return res_ref;
335 }
336 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
337         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
338         CHECK(!val->result_ok);
339         LDKDecodeError err_var = (*val->contents.err);
340         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
341         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
342         long err_ref = (long)err_var.inner & ~1;
343         return err_ref;
344 }
345 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
346         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
347 }
348 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
349         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
350         CHECK(val->result_ok);
351         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
352         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
353         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
354         long res_ref = (long)res_var.inner & ~1;
355         return res_ref;
356 }
357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
358         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
359         CHECK(!val->result_ok);
360         LDKDecodeError err_var = (*val->contents.err);
361         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
362         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
363         long err_ref = (long)err_var.inner & ~1;
364         return err_ref;
365 }
366 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
367         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
368 }
369 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
370         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
371         CHECK(val->result_ok);
372         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
373         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
374         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
375         long res_ref = (long)res_var.inner & ~1;
376         return res_ref;
377 }
378 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
379         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
380         CHECK(!val->result_ok);
381         LDKDecodeError err_var = (*val->contents.err);
382         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
383         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
384         long err_ref = (long)err_var.inner & ~1;
385         return err_ref;
386 }
387 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
388         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
389 }
390 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
391         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
392         CHECK(val->result_ok);
393         LDKCommitmentTransaction res_var = (*val->contents.result);
394         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396         long res_ref = (long)res_var.inner & ~1;
397         return res_ref;
398 }
399 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
400         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
401         CHECK(!val->result_ok);
402         LDKDecodeError err_var = (*val->contents.err);
403         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
404         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
405         long err_ref = (long)err_var.inner & ~1;
406         return err_ref;
407 }
408 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
409         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
410 }
411 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
412         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
413         CHECK(val->result_ok);
414         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
415         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
416         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
417         long res_ref = (long)res_var.inner & ~1;
418         return res_ref;
419 }
420 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
421         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
422         CHECK(!val->result_ok);
423         return *val->contents.err;
424 }
425 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
426         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
427 }
428 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
429         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
430         CHECK(val->result_ok);
431         LDKCVec_SignatureZ res_var = (*val->contents.result);
432         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
433         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
434         for (size_t m = 0; m < res_var.datalen; m++) {
435                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
436                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
437                 res_arr_ptr[m] = res_conv_12_arr;
438         }
439         return res_arr;
440 }
441 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
442         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
443         CHECK(!val->result_ok);
444         return *val->contents.err;
445 }
446 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
447         LDKErrorAction *obj = (LDKErrorAction*)ptr;
448         switch(obj->tag) {
449                 case LDKErrorAction_DisconnectPeer: {
450                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
451                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
452                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
453                         long msg_ref = (long)msg_var.inner & ~1;
454                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
455                 }
456                 case LDKErrorAction_IgnoreError: {
457                         return 0 /* LDKErrorAction - IgnoreError */;
458                 }
459                 case LDKErrorAction_SendErrorMessage: {
460                         LDKErrorMessage msg_var = obj->send_error_message.msg;
461                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463                         long msg_ref = (long)msg_var.inner & ~1;
464                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
465                 }
466                 default: abort();
467         }
468 }
469 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
470         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
471         switch(obj->tag) {
472                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
473                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
474                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
475                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
476                         long msg_ref = (long)msg_var.inner & ~1;
477                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
478                 }
479                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
480                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
481                 }
482                 case LDKHTLCFailChannelUpdate_NodeFailure: {
483                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
484                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
485                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
486                 }
487                 default: abort();
488         }
489 }
490 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
491         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
492         switch(obj->tag) {
493                 case LDKMessageSendEvent_SendAcceptChannel: {
494                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
495                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
496                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
497                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
498                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
499                         long msg_ref = (long)msg_var.inner & ~1;
500                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
501                 }
502                 case LDKMessageSendEvent_SendOpenChannel: {
503                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
504                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
505                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
506                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
507                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
508                         long msg_ref = (long)msg_var.inner & ~1;
509                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
510                 }
511                 case LDKMessageSendEvent_SendFundingCreated: {
512                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
513                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
514                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
515                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
516                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
517                         long msg_ref = (long)msg_var.inner & ~1;
518                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
519                 }
520                 case LDKMessageSendEvent_SendFundingSigned: {
521                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
522                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
523                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
524                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526                         long msg_ref = (long)msg_var.inner & ~1;
527                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
528                 }
529                 case LDKMessageSendEvent_SendFundingLocked: {
530                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
531                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
532                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
533                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
534                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
535                         long msg_ref = (long)msg_var.inner & ~1;
536                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
537                 }
538                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
539                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
540                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
541                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
542                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
543                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
544                         long msg_ref = (long)msg_var.inner & ~1;
545                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
546                 }
547                 case LDKMessageSendEvent_UpdateHTLCs: {
548                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
549                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
550                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
551                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
552                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
553                         long updates_ref = (long)updates_var.inner & ~1;
554                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
555                 }
556                 case LDKMessageSendEvent_SendRevokeAndACK: {
557                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
558                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
559                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
560                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562                         long msg_ref = (long)msg_var.inner & ~1;
563                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
564                 }
565                 case LDKMessageSendEvent_SendClosingSigned: {
566                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
567                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
568                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
569                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
570                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
571                         long msg_ref = (long)msg_var.inner & ~1;
572                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
573                 }
574                 case LDKMessageSendEvent_SendShutdown: {
575                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
576                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
577                         LDKShutdown msg_var = obj->send_shutdown.msg;
578                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
579                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
580                         long msg_ref = (long)msg_var.inner & ~1;
581                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
582                 }
583                 case LDKMessageSendEvent_SendChannelReestablish: {
584                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
585                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
586                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
587                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
588                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
589                         long msg_ref = (long)msg_var.inner & ~1;
590                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
591                 }
592                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
593                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
594                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
595                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
596                         long msg_ref = (long)msg_var.inner & ~1;
597                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
598                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
599                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
600                         long update_msg_ref = (long)update_msg_var.inner & ~1;
601                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
602                 }
603                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
604                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
605                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
606                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
607                         long msg_ref = (long)msg_var.inner & ~1;
608                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
609                 }
610                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
611                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
612                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
613                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
614                         long msg_ref = (long)msg_var.inner & ~1;
615                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
616                 }
617                 case LDKMessageSendEvent_HandleError: {
618                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
619                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
620                         long action_ref = ((long)&obj->handle_error.action) | 1;
621                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
622                 }
623                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
624                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
625                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
626                 }
627                 case LDKMessageSendEvent_SendChannelRangeQuery: {
628                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
629                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
630                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
631                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
632                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
633                         long msg_ref = (long)msg_var.inner & ~1;
634                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
635                 }
636                 case LDKMessageSendEvent_SendShortIdsQuery: {
637                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
638                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
639                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
640                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
641                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
642                         long msg_ref = (long)msg_var.inner & ~1;
643                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
644                 }
645                 default: abort();
646         }
647 }
648 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
649         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
650         ret->datalen = *((uint32_t*)elems);
651         if (ret->datalen == 0) {
652                 ret->data = NULL;
653         } else {
654                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
655                 uint32_t *java_elems = (uint32_t*)(elems + 4);
656                 for (size_t i = 0; i < ret->datalen; i++) {
657                         uint32_t arr_elem = java_elems[i];
658                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
659                         FREE((void*)arr_elem);
660                         ret->data[i] = arr_elem_conv;
661                 }
662         }
663         return (long)ret;
664 }
665 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
666         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
667         for (size_t i = 0; i < ret.datalen; i++) {
668                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
669         }
670         return ret;
671 }
672 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
673         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
674 }
675 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
676         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
677         CHECK(val->result_ok);
678         return *val->contents.result;
679 }
680 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
681         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
682         CHECK(!val->result_ok);
683         LDKLightningError err_var = (*val->contents.err);
684         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
685         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
686         long err_ref = (long)err_var.inner & ~1;
687         return err_ref;
688 }
689 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
690         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
691         LDKChannelAnnouncement a_conv;
692         a_conv.inner = (void*)(a & (~1));
693         a_conv.is_owned = (a & 1) || (a == 0);
694         a_conv = ChannelAnnouncement_clone(&a_conv);
695         ret->a = a_conv;
696         LDKChannelUpdate b_conv;
697         b_conv.inner = (void*)(b & (~1));
698         b_conv.is_owned = (b & 1) || (b == 0);
699         b_conv = ChannelUpdate_clone(&b_conv);
700         ret->b = b_conv;
701         LDKChannelUpdate c_conv;
702         c_conv.inner = (void*)(c & (~1));
703         c_conv.is_owned = (c & 1) || (c == 0);
704         c_conv = ChannelUpdate_clone(&c_conv);
705         ret->c = c_conv;
706         return (long)ret;
707 }
708 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
709         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
710         LDKChannelAnnouncement a_var = tuple->a;
711         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
712         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
713         long a_ref = (long)a_var.inner & ~1;
714         return a_ref;
715 }
716 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
717         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
718         LDKChannelUpdate b_var = tuple->b;
719         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
720         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
721         long b_ref = (long)b_var.inner & ~1;
722         return b_ref;
723 }
724 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
725         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
726         LDKChannelUpdate c_var = tuple->c;
727         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
728         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
729         long c_ref = (long)c_var.inner & ~1;
730         return c_ref;
731 }
732 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
733         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
734         ret->datalen = *((uint32_t*)elems);
735         if (ret->datalen == 0) {
736                 ret->data = NULL;
737         } else {
738                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
739                 uint32_t *java_elems = (uint32_t*)(elems + 4);
740                 for (size_t i = 0; i < ret->datalen; i++) {
741                         uint32_t arr_elem = java_elems[i];
742                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
743                         FREE((void*)arr_elem);
744                         ret->data[i] = arr_elem_conv;
745                 }
746         }
747         return (long)ret;
748 }
749 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
750         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
751         for (size_t i = 0; i < ret.datalen; i++) {
752                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
753         }
754         return ret;
755 }
756 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
757         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
758         ret->datalen = *((uint32_t*)elems);
759         if (ret->datalen == 0) {
760                 ret->data = NULL;
761         } else {
762                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
763                 uint32_t *java_elems = (uint32_t*)(elems + 4);
764                 for (size_t i = 0; i < ret->datalen; i++) {
765                         uint32_t arr_elem = java_elems[i];
766                         LDKNodeAnnouncement arr_elem_conv;
767                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
768                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
769                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
770                         ret->data[i] = arr_elem_conv;
771                 }
772         }
773         return (long)ret;
774 }
775 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
776         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
777         for (size_t i = 0; i < ret.datalen; i++) {
778                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
779         }
780         return ret;
781 }
782 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
783         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
784 }
785 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
786         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
787         CHECK(val->result_ok);
788         return *val->contents.result;
789 }
790 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
791         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
792         CHECK(!val->result_ok);
793         LDKLightningError err_var = (*val->contents.err);
794         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
795         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
796         long err_ref = (long)err_var.inner & ~1;
797         return err_ref;
798 }
799 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
800         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
801 }
802 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
803         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
804         CHECK(val->result_ok);
805         LDKCVec_u8Z res_var = (*val->contents.result);
806         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
807         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
808         return res_arr;
809 }
810 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
811         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
812         CHECK(!val->result_ok);
813         LDKPeerHandleError err_var = (*val->contents.err);
814         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
815         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
816         long err_ref = (long)err_var.inner & ~1;
817         return err_ref;
818 }
819 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
820         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
821 }
822 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
823         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
824         CHECK(val->result_ok);
825         return *val->contents.result;
826 }
827 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
828         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
829         CHECK(!val->result_ok);
830         LDKPeerHandleError err_var = (*val->contents.err);
831         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
832         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
833         long err_ref = (long)err_var.inner & ~1;
834         return err_ref;
835 }
836 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
837         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
838 }
839 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
840         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
841         CHECK(val->result_ok);
842         return *val->contents.result;
843 }
844 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
845         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
846         CHECK(!val->result_ok);
847         LDKPeerHandleError err_var = (*val->contents.err);
848         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
849         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
850         long err_ref = (long)err_var.inner & ~1;
851         return err_ref;
852 }
853 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
854         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
855 }
856 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
857         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
858         CHECK(val->result_ok);
859         LDKInitFeatures res_var = (*val->contents.result);
860         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
861         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
862         long res_ref = (long)res_var.inner & ~1;
863         return res_ref;
864 }
865 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
866         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
867         CHECK(!val->result_ok);
868         LDKDecodeError err_var = (*val->contents.err);
869         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
870         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
871         long err_ref = (long)err_var.inner & ~1;
872         return err_ref;
873 }
874 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
875         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
876 }
877 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
878         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
879         CHECK(val->result_ok);
880         LDKNodeFeatures res_var = (*val->contents.result);
881         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
882         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
883         long res_ref = (long)res_var.inner & ~1;
884         return res_ref;
885 }
886 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
887         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
888         CHECK(!val->result_ok);
889         LDKDecodeError err_var = (*val->contents.err);
890         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
891         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
892         long err_ref = (long)err_var.inner & ~1;
893         return err_ref;
894 }
895 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
896         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
897 }
898 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
899         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
900         CHECK(val->result_ok);
901         LDKChannelFeatures res_var = (*val->contents.result);
902         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
903         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
904         long res_ref = (long)res_var.inner & ~1;
905         return res_ref;
906 }
907 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
908         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
909         CHECK(!val->result_ok);
910         LDKDecodeError err_var = (*val->contents.err);
911         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         long err_ref = (long)err_var.inner & ~1;
914         return err_ref;
915 }
916 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
917         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
918 }
919 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
920         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
921         CHECK(val->result_ok);
922         LDKChannelConfig res_var = (*val->contents.result);
923         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
924         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
925         long res_ref = (long)res_var.inner & ~1;
926         return res_ref;
927 }
928 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
929         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
930         CHECK(!val->result_ok);
931         LDKDecodeError err_var = (*val->contents.err);
932         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934         long err_ref = (long)err_var.inner & ~1;
935         return err_ref;
936 }
937 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
938         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
939 }
940 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
941         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
942         CHECK(val->result_ok);
943         LDKDirectionalChannelInfo res_var = (*val->contents.result);
944         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
945         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
946         long res_ref = (long)res_var.inner & ~1;
947         return res_ref;
948 }
949 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
950         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
951         CHECK(!val->result_ok);
952         LDKDecodeError err_var = (*val->contents.err);
953         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955         long err_ref = (long)err_var.inner & ~1;
956         return err_ref;
957 }
958 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
959         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
960 }
961 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
962         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
963         CHECK(val->result_ok);
964         LDKChannelInfo res_var = (*val->contents.result);
965         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
966         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
967         long res_ref = (long)res_var.inner & ~1;
968         return res_ref;
969 }
970 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
971         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
972         CHECK(!val->result_ok);
973         LDKDecodeError err_var = (*val->contents.err);
974         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
975         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
976         long err_ref = (long)err_var.inner & ~1;
977         return err_ref;
978 }
979 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
980         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
981 }
982 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
983         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
984         CHECK(val->result_ok);
985         LDKRoutingFees res_var = (*val->contents.result);
986         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
987         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
988         long res_ref = (long)res_var.inner & ~1;
989         return res_ref;
990 }
991 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
992         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
993         CHECK(!val->result_ok);
994         LDKDecodeError err_var = (*val->contents.err);
995         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
996         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
997         long err_ref = (long)err_var.inner & ~1;
998         return err_ref;
999 }
1000 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1001         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1002         switch(obj->tag) {
1003                 case LDKNetAddress_IPv4: {
1004                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1005                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1006                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1007                 }
1008                 case LDKNetAddress_IPv6: {
1009                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1010                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1011                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1012                 }
1013                 case LDKNetAddress_OnionV2: {
1014                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1015                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1016                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1017                 }
1018                 case LDKNetAddress_OnionV3: {
1019                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1020                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1021                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1022                 }
1023                 default: abort();
1024         }
1025 }
1026 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1027         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1028         ret->datalen = *((uint32_t*)elems);
1029         if (ret->datalen == 0) {
1030                 ret->data = NULL;
1031         } else {
1032                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1033                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1034                 for (size_t i = 0; i < ret->datalen; i++) {
1035                         uint32_t arr_elem = java_elems[i];
1036                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1037                         FREE((void*)arr_elem);
1038                         ret->data[i] = arr_elem_conv;
1039                 }
1040         }
1041         return (long)ret;
1042 }
1043 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1044         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1045         for (size_t i = 0; i < ret.datalen; i++) {
1046                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1047         }
1048         return ret;
1049 }
1050 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
1051         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1052 }
1053 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
1054         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1055         CHECK(val->result_ok);
1056         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1057         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1058         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1059         long res_ref = (long)res_var.inner & ~1;
1060         return res_ref;
1061 }
1062 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
1063         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1064         CHECK(!val->result_ok);
1065         LDKDecodeError err_var = (*val->contents.err);
1066         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1067         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1068         long err_ref = (long)err_var.inner & ~1;
1069         return err_ref;
1070 }
1071 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
1072         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1073         ret->datalen = *((uint32_t*)elems);
1074         if (ret->datalen == 0) {
1075                 ret->data = NULL;
1076         } else {
1077                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1078                 int64_t *java_elems = (int64_t*)(elems + 4);
1079                 for (size_t i = 0; i < ret->datalen; i++) {
1080                         ret->data[i] = java_elems[i];
1081                 }
1082         }
1083         return (long)ret;
1084 }
1085 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1086         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1087         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1088         return ret;
1089 }
1090 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
1091         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1092 }
1093 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
1094         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1095         CHECK(val->result_ok);
1096         LDKNodeInfo res_var = (*val->contents.result);
1097         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1098         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1099         long res_ref = (long)res_var.inner & ~1;
1100         return res_ref;
1101 }
1102 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
1103         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1104         CHECK(!val->result_ok);
1105         LDKDecodeError err_var = (*val->contents.err);
1106         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         long err_ref = (long)err_var.inner & ~1;
1109         return err_ref;
1110 }
1111 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
1112         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1113 }
1114 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
1115         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1116         CHECK(val->result_ok);
1117         LDKNetworkGraph res_var = (*val->contents.result);
1118         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1119         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1120         long res_ref = (long)res_var.inner & ~1;
1121         return res_ref;
1122 }
1123 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
1124         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1125         CHECK(!val->result_ok);
1126         LDKDecodeError err_var = (*val->contents.err);
1127         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1128         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1129         long err_ref = (long)err_var.inner & ~1;
1130         return err_ref;
1131 }
1132 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
1133         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1134         ret->a = a;
1135         LDKTransaction b_ref;
1136         b_ref.datalen = *((uint32_t*)b);
1137         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1138         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1139         b_ref.data_is_owned = false;
1140         ret->b = b_ref;
1141         return (long)ret;
1142 }
1143 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
1144         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1145         return tuple->a;
1146 }
1147 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
1148         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1149         LDKTransaction b_var = tuple->b;
1150         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1151         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1152         return b_arr;
1153 }
1154 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
1155         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1156         ret->datalen = *((uint32_t*)elems);
1157         if (ret->datalen == 0) {
1158                 ret->data = NULL;
1159         } else {
1160                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1161                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1162                 for (size_t i = 0; i < ret->datalen; i++) {
1163                         uint32_t arr_elem = java_elems[i];
1164                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1165                         FREE((void*)arr_elem);
1166                         ret->data[i] = arr_elem_conv;
1167                 }
1168         }
1169         return (long)ret;
1170 }
1171 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
1172         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1173 }
1174 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
1175         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1176         CHECK(val->result_ok);
1177         return *val->contents.result;
1178 }
1179 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
1180         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1181         CHECK(!val->result_ok);
1182         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
1183         return err_conv;
1184 }
1185 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
1186         LDKMonitorEvent *obj = (LDKMonitorEvent*)ptr;
1187         switch(obj->tag) {
1188                 case LDKMonitorEvent_HTLCEvent: {
1189                         return 0 /* LDKMonitorEvent - HTLCEvent */;
1190                 }
1191                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1192                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */;
1193                 }
1194                 default: abort();
1195         }
1196 }
1197 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
1198         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1199         ret->datalen = *((uint32_t*)elems);
1200         if (ret->datalen == 0) {
1201                 ret->data = NULL;
1202         } else {
1203                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1204                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1205                 for (size_t i = 0; i < ret->datalen; i++) {
1206                         uint32_t arr_elem = java_elems[i];
1207                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1208                         FREE((void*)arr_elem);
1209                         ret->data[i] = arr_elem_conv;
1210                 }
1211         }
1212         return (long)ret;
1213 }
1214 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1215         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1216         for (size_t i = 0; i < ret.datalen; i++) {
1217                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1218         }
1219         return ret;
1220 }
1221 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1222         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
1223         switch(obj->tag) {
1224                 case LDKSpendableOutputDescriptor_StaticOutput: {
1225                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1226                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1227                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1228                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1229                         long output_ref = ((long)&obj->static_output.output) | 1;
1230                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
1231                 }
1232                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1233                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */;
1234                 }
1235                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1236                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */;
1237                 }
1238                 default: abort();
1239         }
1240 }
1241 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1242         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1243         ret->datalen = *((uint32_t*)elems);
1244         if (ret->datalen == 0) {
1245                 ret->data = NULL;
1246         } else {
1247                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1248                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1249                 for (size_t i = 0; i < ret->datalen; i++) {
1250                         uint32_t arr_elem = java_elems[i];
1251                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1252                         FREE((void*)arr_elem);
1253                         ret->data[i] = arr_elem_conv;
1254                 }
1255         }
1256         return (long)ret;
1257 }
1258 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1259         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1260         for (size_t i = 0; i < ret.datalen; i++) {
1261                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1262         }
1263         return ret;
1264 }
1265 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
1266         LDKEvent *obj = (LDKEvent*)ptr;
1267         switch(obj->tag) {
1268                 case LDKEvent_FundingGenerationReady: {
1269                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1270                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
1271                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1272                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1273                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
1274                         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;
1275                 }
1276                 case LDKEvent_FundingBroadcastSafe: {
1277                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1278                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1281                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
1282                 }
1283                 case LDKEvent_PaymentReceived: {
1284                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1285                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
1286                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1287                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
1288                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
1289                 }
1290                 case LDKEvent_PaymentSent: {
1291                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1292                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
1293                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
1294                 }
1295                 case LDKEvent_PaymentFailed: {
1296                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1297                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
1298                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
1299                 }
1300                 case LDKEvent_PendingHTLCsForwardable: {
1301                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
1302                 }
1303                 case LDKEvent_SpendableOutputs: {
1304                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1305                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1306                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
1307                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1308                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1309                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1310                         }
1311                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
1312                 }
1313                 default: abort();
1314         }
1315 }
1316 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
1317         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1318         ret->datalen = *((uint32_t*)elems);
1319         if (ret->datalen == 0) {
1320                 ret->data = NULL;
1321         } else {
1322                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1323                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1324                 for (size_t i = 0; i < ret->datalen; i++) {
1325                         uint32_t arr_elem = java_elems[i];
1326                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1327                         FREE((void*)arr_elem);
1328                         ret->data[i] = arr_elem_conv;
1329                 }
1330         }
1331         return (long)ret;
1332 }
1333 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1334         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1335         for (size_t i = 0; i < ret.datalen; i++) {
1336                 ret.data[i] = Event_clone(&orig->data[i]);
1337         }
1338         return ret;
1339 }
1340 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
1341         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1342 }
1343 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
1344         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1345         CHECK(val->result_ok);
1346         LDKOutPoint res_var = (*val->contents.result);
1347         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         long res_ref = (long)res_var.inner & ~1;
1350         return res_ref;
1351 }
1352 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
1353         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1354         CHECK(!val->result_ok);
1355         LDKDecodeError err_var = (*val->contents.err);
1356         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1357         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1358         long err_ref = (long)err_var.inner & ~1;
1359         return err_ref;
1360 }
1361 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1362         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1363 }
1364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1365         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1366         CHECK(val->result_ok);
1367         LDKChannelMonitorUpdate res_var = (*val->contents.result);
1368         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370         long res_ref = (long)res_var.inner & ~1;
1371         return res_ref;
1372 }
1373 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
1374         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1375         CHECK(!val->result_ok);
1376         LDKDecodeError err_var = (*val->contents.err);
1377         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1378         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1379         long err_ref = (long)err_var.inner & ~1;
1380         return err_ref;
1381 }
1382 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1383         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
1384 }
1385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1386         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1387         CHECK(val->result_ok);
1388         LDKHTLCUpdate res_var = (*val->contents.result);
1389         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1390         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1391         long res_ref = (long)res_var.inner & ~1;
1392         return res_ref;
1393 }
1394 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
1395         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1396         CHECK(!val->result_ok);
1397         LDKDecodeError err_var = (*val->contents.err);
1398         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1399         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1400         long err_ref = (long)err_var.inner & ~1;
1401         return err_ref;
1402 }
1403 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
1404         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
1405 }
1406 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
1407         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1408         CHECK(val->result_ok);
1409         return *val->contents.result;
1410 }
1411 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
1412         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1413         CHECK(!val->result_ok);
1414         LDKMonitorUpdateError err_var = (*val->contents.err);
1415         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1416         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1417         long err_ref = (long)err_var.inner & ~1;
1418         return err_ref;
1419 }
1420 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
1421         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
1422         LDKOutPoint a_conv;
1423         a_conv.inner = (void*)(a & (~1));
1424         a_conv.is_owned = (a & 1) || (a == 0);
1425         a_conv = OutPoint_clone(&a_conv);
1426         ret->a = a_conv;
1427         LDKCVec_u8Z b_ref;
1428         b_ref.datalen = *((uint32_t*)b);
1429         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1430         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1431         ret->b = b_ref;
1432         return (long)ret;
1433 }
1434 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
1435         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1436         LDKOutPoint a_var = tuple->a;
1437         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1438         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1439         long a_ref = (long)a_var.inner & ~1;
1440         return a_ref;
1441 }
1442 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
1443         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1444         LDKCVec_u8Z b_var = tuple->b;
1445         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1446         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1447         return b_arr;
1448 }
1449 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
1450         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
1451         ret->a = a;
1452         LDKCVec_u8Z b_ref;
1453         b_ref.datalen = *((uint32_t*)b);
1454         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1455         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1456         ret->b = b_ref;
1457         return (long)ret;
1458 }
1459 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
1460         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1461         return tuple->a;
1462 }
1463 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
1464         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1465         LDKCVec_u8Z b_var = tuple->b;
1466         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1467         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1468         return b_arr;
1469 }
1470 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
1471         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
1472         ret->datalen = *((uint32_t*)elems);
1473         if (ret->datalen == 0) {
1474                 ret->data = NULL;
1475         } else {
1476                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
1477                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1478                 for (size_t i = 0; i < ret->datalen; i++) {
1479                         uint32_t arr_elem = java_elems[i];
1480                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
1481                         FREE((void*)arr_elem);
1482                         ret->data[i] = arr_elem_conv;
1483                 }
1484         }
1485         return (long)ret;
1486 }
1487 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
1488         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
1489         for (size_t i = 0; i < ret.datalen; i++) {
1490                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
1491         }
1492         return ret;
1493 }
1494 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
1495         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
1496         LDKThirtyTwoBytes a_ref;
1497         CHECK(*((uint32_t*)a) == 32);
1498         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1499         ret->a = a_ref;
1500         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
1501         b_constr.datalen = *((uint32_t*)b);
1502         if (b_constr.datalen > 0)
1503                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
1504         else
1505                 b_constr.data = NULL;
1506         uint32_t* b_vals = (uint32_t*)(b + 4);
1507         for (size_t e = 0; e < b_constr.datalen; e++) {
1508                 uint32_t b_conv_30 = b_vals[e];
1509                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
1510                 FREE((void*)b_conv_30);
1511                 b_constr.data[e] = b_conv_30_conv;
1512         }
1513         ret->b = b_constr;
1514         return (long)ret;
1515 }
1516 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
1517         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1518         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1519         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1520         return a_arr;
1521 }
1522 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
1523         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1524         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
1525         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1526         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1527         for (size_t e = 0; e < b_var.datalen; e++) {
1528                 long b_conv_30_ref = (long)(&b_var.data[e]) | 1;
1529                 b_arr_ptr[e] = b_conv_30_ref;
1530         }
1531         return b_arr;
1532 }
1533 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
1534         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
1535         ret->datalen = *((uint32_t*)elems);
1536         if (ret->datalen == 0) {
1537                 ret->data = NULL;
1538         } else {
1539                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
1540                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1541                 for (size_t i = 0; i < ret->datalen; i++) {
1542                         uint32_t arr_elem = java_elems[i];
1543                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
1544                         FREE((void*)arr_elem);
1545                         ret->data[i] = arr_elem_conv;
1546                 }
1547         }
1548         return (long)ret;
1549 }
1550 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
1551         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1552         ret->a = a;
1553         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1554         FREE((void*)b);
1555         ret->b = b_conv;
1556         return (long)ret;
1557 }
1558 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
1559         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1560         return tuple->a;
1561 }
1562 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
1563         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1564         long b_ref = ((long)&tuple->b) | 1;
1565         return (long)b_ref;
1566 }
1567 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
1568         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1569         ret->datalen = *((uint32_t*)elems);
1570         if (ret->datalen == 0) {
1571                 ret->data = NULL;
1572         } else {
1573                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1574                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1575                 for (size_t i = 0; i < ret->datalen; i++) {
1576                         uint32_t arr_elem = java_elems[i];
1577                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1578                         FREE((void*)arr_elem);
1579                         ret->data[i] = arr_elem_conv;
1580                 }
1581         }
1582         return (long)ret;
1583 }
1584 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1585         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1586         for (size_t i = 0; i < ret.datalen; i++) {
1587                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1588         }
1589         return ret;
1590 }
1591 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
1592         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
1593         LDKThirtyTwoBytes a_ref;
1594         CHECK(*((uint32_t*)a) == 32);
1595         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1596         ret->a = a_ref;
1597         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
1598         b_constr.datalen = *((uint32_t*)b);
1599         if (b_constr.datalen > 0)
1600                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
1601         else
1602                 b_constr.data = NULL;
1603         uint32_t* b_vals = (uint32_t*)(b + 4);
1604         for (size_t z = 0; z < b_constr.datalen; z++) {
1605                 uint32_t b_conv_25 = b_vals[z];
1606                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
1607                 FREE((void*)b_conv_25);
1608                 b_constr.data[z] = b_conv_25_conv;
1609         }
1610         ret->b = b_constr;
1611         return (long)ret;
1612 }
1613 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
1614         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1615         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1616         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1617         return a_arr;
1618 }
1619 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
1620         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1621         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1622         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1623         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1624         for (size_t z = 0; z < b_var.datalen; z++) {
1625                 long b_conv_25_ref = (long)(&b_var.data[z]) | 1;
1626                 b_arr_ptr[z] = b_conv_25_ref;
1627         }
1628         return b_arr;
1629 }
1630 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
1631         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1632         ret->datalen = *((uint32_t*)elems);
1633         if (ret->datalen == 0) {
1634                 ret->data = NULL;
1635         } else {
1636                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1637                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1638                 for (size_t i = 0; i < ret->datalen; i++) {
1639                         uint32_t arr_elem = java_elems[i];
1640                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1641                         FREE((void*)arr_elem);
1642                         ret->data[i] = arr_elem_conv;
1643                 }
1644         }
1645         return (long)ret;
1646 }
1647 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1648         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1649         LDKSignature a_ref;
1650         CHECK(*((uint32_t*)a) == 64);
1651         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1652         ret->a = a_ref;
1653         LDKCVec_SignatureZ b_constr;
1654         b_constr.datalen = *((uint32_t*)b);
1655         if (b_constr.datalen > 0)
1656                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1657         else
1658                 b_constr.data = NULL;
1659         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1660         for (size_t m = 0; m < b_constr.datalen; m++) {
1661                 int8_tArray b_conv_12 = b_vals[m];
1662                 LDKSignature b_conv_12_ref;
1663                 CHECK(*((uint32_t*)b_conv_12) == 64);
1664                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1665                 b_constr.data[m] = b_conv_12_ref;
1666         }
1667         ret->b = b_constr;
1668         return (long)ret;
1669 }
1670 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1671         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1672         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1673         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1674         return a_arr;
1675 }
1676 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1677         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1678         LDKCVec_SignatureZ b_var = tuple->b;
1679         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1680         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1681         for (size_t m = 0; m < b_var.datalen; m++) {
1682                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1683                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1684                 b_arr_ptr[m] = b_conv_12_arr;
1685         }
1686         return b_arr;
1687 }
1688 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1689         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1690 }
1691 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1692         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1693         CHECK(val->result_ok);
1694         long res_ref = (long)(&(*val->contents.result)) | 1;
1695         return res_ref;
1696 }
1697 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1698         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1699         CHECK(!val->result_ok);
1700         return *val->contents.err;
1701 }
1702 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1703         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1704 }
1705 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1706         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1707         CHECK(val->result_ok);
1708         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1709         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1710         return res_arr;
1711 }
1712 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1713         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1714         CHECK(!val->result_ok);
1715         return *val->contents.err;
1716 }
1717 typedef struct LDKSign_JCalls {
1718         atomic_size_t refcnt;
1719         uint32_t get_per_commitment_point_meth;
1720         uint32_t release_commitment_secret_meth;
1721         uint32_t channel_keys_id_meth;
1722         uint32_t sign_counterparty_commitment_meth;
1723         uint32_t sign_holder_commitment_and_htlcs_meth;
1724         uint32_t sign_justice_transaction_meth;
1725         uint32_t sign_counterparty_htlc_transaction_meth;
1726         uint32_t sign_closing_transaction_meth;
1727         uint32_t sign_channel_announcement_meth;
1728         uint32_t ready_channel_meth;
1729         uint32_t write_meth;
1730 } LDKSign_JCalls;
1731 static void LDKSign_JCalls_free(void* this_arg) {
1732         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1733         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1734                 js_free(j_calls->get_per_commitment_point_meth);
1735                 js_free(j_calls->release_commitment_secret_meth);
1736                 js_free(j_calls->channel_keys_id_meth);
1737                 js_free(j_calls->sign_counterparty_commitment_meth);
1738                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1739                 js_free(j_calls->sign_justice_transaction_meth);
1740                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1741                 js_free(j_calls->sign_closing_transaction_meth);
1742                 js_free(j_calls->sign_channel_announcement_meth);
1743                 js_free(j_calls->ready_channel_meth);
1744                 js_free(j_calls->write_meth);
1745                 FREE(j_calls);
1746         }
1747 }
1748 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1749         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1750         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1751         LDKPublicKey ret_ref;
1752         CHECK(*((uint32_t*)ret) == 33);
1753         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1754         return ret_ref;
1755 }
1756 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1757         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1758         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1759         LDKThirtyTwoBytes ret_ref;
1760         CHECK(*((uint32_t*)ret) == 32);
1761         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1762         return ret_ref;
1763 }
1764 LDKThirtyTwoBytes channel_keys_id_jcall(const void* this_arg) {
1765         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1766         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1767         LDKThirtyTwoBytes ret_ref;
1768         CHECK(*((uint32_t*)ret) == 32);
1769         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1770         return ret_ref;
1771 }
1772 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1773         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1774         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1775         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1776         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1777         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1778         long commitment_tx_ref = (long)commitment_tx_var.inner;
1779         if (commitment_tx_var.is_owned) {
1780                 commitment_tx_ref |= 1;
1781         }
1782         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1783         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1784         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
1785         return ret_conv;
1786 }
1787 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1788         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1789         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1790         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1791         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1792         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1793         long commitment_tx_ref = (long)commitment_tx_var.inner;
1794         if (commitment_tx_var.is_owned) {
1795                 commitment_tx_ref |= 1;
1796         }
1797         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1798         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1799         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
1800         return ret_conv;
1801 }
1802 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1803         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1804         LDKTransaction justice_tx_var = justice_tx;
1805         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1806         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1807         Transaction_free(justice_tx_var);
1808         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1809         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1810         LDKHTLCOutputInCommitment htlc_var = *htlc;
1811         htlc_var = HTLCOutputInCommitment_clone(htlc);
1812         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1813         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1814         long htlc_ref = (long)htlc_var.inner;
1815         if (htlc_var.is_owned) {
1816                 htlc_ref |= 1;
1817         }
1818         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1819         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1820         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1821         return ret_conv;
1822 }
1823 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1824         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1825         LDKTransaction htlc_tx_var = htlc_tx;
1826         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1827         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1828         Transaction_free(htlc_tx_var);
1829         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1830         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1831         LDKHTLCOutputInCommitment htlc_var = *htlc;
1832         htlc_var = HTLCOutputInCommitment_clone(htlc);
1833         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835         long htlc_ref = (long)htlc_var.inner;
1836         if (htlc_var.is_owned) {
1837                 htlc_ref |= 1;
1838         }
1839         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1840         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1841         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1842         return ret_conv;
1843 }
1844 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1845         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1846         LDKTransaction closing_tx_var = closing_tx;
1847         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1848         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1849         Transaction_free(closing_tx_var);
1850         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1851         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1852         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1853         return ret_conv;
1854 }
1855 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1856         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1857         LDKUnsignedChannelAnnouncement msg_var = *msg;
1858         msg_var = UnsignedChannelAnnouncement_clone(msg);
1859         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1860         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1861         long msg_ref = (long)msg_var.inner;
1862         if (msg_var.is_owned) {
1863                 msg_ref |= 1;
1864         }
1865         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1866         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1867         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1868         return ret_conv;
1869 }
1870 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1871         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1872         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1873         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1874         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1875         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1876         long channel_parameters_ref = (long)channel_parameters_var.inner;
1877         if (channel_parameters_var.is_owned) {
1878                 channel_parameters_ref |= 1;
1879         }
1880         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1881 }
1882 LDKCVec_u8Z write_jcall(const void* this_arg) {
1883         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1884         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1885         LDKCVec_u8Z ret_ref;
1886         ret_ref.datalen = *((uint32_t*)ret);
1887         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1888         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1889         return ret_ref;
1890 }
1891 static void* LDKSign_JCalls_clone(const void* this_arg) {
1892         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1893         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1894         return (void*) this_arg;
1895 }
1896 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1897         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1898         atomic_init(&calls->refcnt, 1);
1899         //TODO: Assign calls->o from o
1900
1901         LDKChannelPublicKeys pubkeys_conv;
1902         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1903         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1904         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1905
1906         LDKSign ret = {
1907                 .this_arg = (void*) calls,
1908                 .get_per_commitment_point = get_per_commitment_point_jcall,
1909                 .release_commitment_secret = release_commitment_secret_jcall,
1910                 .channel_keys_id = channel_keys_id_jcall,
1911                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1912                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
1913                 .sign_justice_transaction = sign_justice_transaction_jcall,
1914                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1915                 .sign_closing_transaction = sign_closing_transaction_jcall,
1916                 .sign_channel_announcement = sign_channel_announcement_jcall,
1917                 .ready_channel = ready_channel_jcall,
1918                 .clone = LDKSign_JCalls_clone,
1919                 .write = write_jcall,
1920                 .free = LDKSign_JCalls_free,
1921                 .pubkeys = pubkeys_conv,
1922                 .set_pubkeys = NULL,
1923         };
1924         return ret;
1925 }
1926 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1927         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1928         *res_ptr = LDKSign_init(o, pubkeys);
1929         return (long)res_ptr;
1930 }
1931 int8_tArray  __attribute__((visibility("default"))) TS_Sign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1932         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1933         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1934         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1935         return ret_arr;
1936 }
1937
1938 int8_tArray  __attribute__((visibility("default"))) TS_Sign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1939         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1940         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1941         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1942         return ret_arr;
1943 }
1944
1945 int8_tArray  __attribute__((visibility("default"))) TS_Sign_channel_keys_id(uint32_t this_arg) {
1946         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1947         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1948         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1949         return ret_arr;
1950 }
1951
1952 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1953         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1954         LDKCommitmentTransaction commitment_tx_conv;
1955         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1956         commitment_tx_conv.is_owned = false;
1957         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1958         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1959         return (long)ret_conv;
1960 }
1961
1962 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1963         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1964         LDKHolderCommitmentTransaction commitment_tx_conv;
1965         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1966         commitment_tx_conv.is_owned = false;
1967         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1968         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1969         return (long)ret_conv;
1970 }
1971
1972 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_justice_transaction(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1973         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1974         LDKTransaction justice_tx_ref;
1975         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1976         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1977         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1978         justice_tx_ref.data_is_owned = true;
1979         unsigned char per_commitment_key_arr[32];
1980         CHECK(*((uint32_t*)per_commitment_key) == 32);
1981         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1982         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1983         LDKHTLCOutputInCommitment htlc_conv;
1984         htlc_conv.inner = (void*)(htlc & (~1));
1985         htlc_conv.is_owned = false;
1986         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1987         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1988         return (long)ret_conv;
1989 }
1990
1991 uint32_t  __attribute__((visibility("default"))) TS_Sign_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) {
1992         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1993         LDKTransaction htlc_tx_ref;
1994         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1995         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1996         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1997         htlc_tx_ref.data_is_owned = true;
1998         LDKPublicKey per_commitment_point_ref;
1999         CHECK(*((uint32_t*)per_commitment_point) == 33);
2000         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2001         LDKHTLCOutputInCommitment htlc_conv;
2002         htlc_conv.inner = (void*)(htlc & (~1));
2003         htlc_conv.is_owned = false;
2004         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2005         *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);
2006         return (long)ret_conv;
2007 }
2008
2009 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
2010         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2011         LDKTransaction closing_tx_ref;
2012         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
2013         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2014         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
2015         closing_tx_ref.data_is_owned = true;
2016         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2017         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2018         return (long)ret_conv;
2019 }
2020
2021 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2022         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2023         LDKUnsignedChannelAnnouncement msg_conv;
2024         msg_conv.inner = (void*)(msg & (~1));
2025         msg_conv.is_owned = false;
2026         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2027         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2028         return (long)ret_conv;
2029 }
2030
2031 void  __attribute__((visibility("default"))) TS_Sign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2032         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2033         LDKChannelTransactionParameters channel_parameters_conv;
2034         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2035         channel_parameters_conv.is_owned = false;
2036         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2037 }
2038
2039 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2040         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2041         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2042         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2043         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2044         CVec_u8Z_free(ret_var);
2045         return ret_arr;
2046 }
2047
2048 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2049         if (this_arg->set_pubkeys != NULL)
2050                 this_arg->set_pubkeys(this_arg);
2051         return this_arg->pubkeys;
2052 }
2053 uint32_t  __attribute__((visibility("default"))) TS_Sign_get_pubkeys(uint32_t this_arg) {
2054         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2055         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2056         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2057         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2058         long ret_ref = (long)ret_var.inner;
2059         if (ret_var.is_owned) {
2060                 ret_ref |= 1;
2061         }
2062         return ret_ref;
2063 }
2064
2065 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2066         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2067         LDKThirtyTwoBytes a_ref;
2068         CHECK(*((uint32_t*)a) == 32);
2069         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2070         ret->a = a_ref;
2071         LDKChannelMonitor b_conv;
2072         b_conv.inner = (void*)(b & (~1));
2073         b_conv.is_owned = (b & 1) || (b == 0);
2074         b_conv = ChannelMonitor_clone(&b_conv);
2075         ret->b = b_conv;
2076         return (long)ret;
2077 }
2078 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
2079         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2080         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2081         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2082         return a_arr;
2083 }
2084 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
2085         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2086         LDKChannelMonitor b_var = tuple->b;
2087         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089         long b_ref = (long)b_var.inner & ~1;
2090         return b_ref;
2091 }
2092 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
2093         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2094 }
2095 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
2096         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2097         CHECK(val->result_ok);
2098         long res_ref = (long)(&(*val->contents.result)) | 1;
2099         return res_ref;
2100 }
2101 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
2102         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2103         CHECK(!val->result_ok);
2104         LDKDecodeError err_var = (*val->contents.err);
2105         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2106         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2107         long err_ref = (long)err_var.inner & ~1;
2108         return err_ref;
2109 }
2110 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
2111         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2112 }
2113 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
2114         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2115         CHECK(val->result_ok);
2116         long res_ref = ((long)&(*val->contents.result)) | 1;
2117         return (long)res_ref;
2118 }
2119 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
2120         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2121         CHECK(!val->result_ok);
2122         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
2123         return err_conv;
2124 }
2125 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2126         LDKAPIError *obj = (LDKAPIError*)ptr;
2127         switch(obj->tag) {
2128                 case LDKAPIError_APIMisuseError: {
2129                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2130                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2131                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2132                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
2133                 }
2134                 case LDKAPIError_FeeRateTooHigh: {
2135                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2136                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2137                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2138                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
2139                 }
2140                 case LDKAPIError_RouteError: {
2141                         LDKStr err_str = obj->route_error.err;
2142                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2143                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2144                 }
2145                 case LDKAPIError_ChannelUnavailable: {
2146                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2147                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2148                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2149                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
2150                 }
2151                 case LDKAPIError_MonitorUpdateFailed: {
2152                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2153                 }
2154                 default: abort();
2155         }
2156 }
2157 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2158         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2159 }
2160 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2161         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2162         CHECK(val->result_ok);
2163         return *val->contents.result;
2164 }
2165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2166         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2167         CHECK(!val->result_ok);
2168         long err_ref = ((long)&(*val->contents.err)) | 1;
2169         return err_ref;
2170 }
2171 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2172         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2173         ret->datalen = *((uint32_t*)elems);
2174         if (ret->datalen == 0) {
2175                 ret->data = NULL;
2176         } else {
2177                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2178                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2179                 for (size_t i = 0; i < ret->datalen; i++) {
2180                         uint32_t arr_elem = java_elems[i];
2181                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2182                         FREE((void*)arr_elem);
2183                         ret->data[i] = arr_elem_conv;
2184                 }
2185         }
2186         return (long)ret;
2187 }
2188 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2189         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2190         for (size_t i = 0; i < ret.datalen; i++) {
2191                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2192         }
2193         return ret;
2194 }
2195 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2196         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2197         ret->datalen = *((uint32_t*)elems);
2198         if (ret->datalen == 0) {
2199                 ret->data = NULL;
2200         } else {
2201                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2202                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2203                 for (size_t i = 0; i < ret->datalen; i++) {
2204                         uint32_t arr_elem = java_elems[i];
2205                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2206                         FREE((void*)arr_elem);
2207                         ret->data[i] = arr_elem_conv;
2208                 }
2209         }
2210         return (long)ret;
2211 }
2212 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2213         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2214         for (size_t i = 0; i < ret.datalen; i++) {
2215                 ret.data[i] = APIError_clone(&orig->data[i]);
2216         }
2217         return ret;
2218 }
2219 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
2220         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2221         ret->datalen = *((uint32_t*)elems);
2222         if (ret->datalen == 0) {
2223                 ret->data = NULL;
2224         } else {
2225                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2226                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2227                 for (size_t i = 0; i < ret->datalen; i++) {
2228                         uint32_t arr_elem = java_elems[i];
2229                         LDKChannelDetails arr_elem_conv;
2230                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2231                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2232                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2233                         ret->data[i] = arr_elem_conv;
2234                 }
2235         }
2236         return (long)ret;
2237 }
2238 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2239         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2240         for (size_t i = 0; i < ret.datalen; i++) {
2241                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2242         }
2243         return ret;
2244 }
2245 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2246         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)ptr;
2247         switch(obj->tag) {
2248                 case LDKPaymentSendFailure_ParameterError: {
2249                         return 0 /* LDKPaymentSendFailure - ParameterError */;
2250                 }
2251                 case LDKPaymentSendFailure_PathParameterError: {
2252                         return 0 /* LDKPaymentSendFailure - PathParameterError */;
2253                 }
2254                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2255                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */;
2256                 }
2257                 case LDKPaymentSendFailure_PartialFailure: {
2258                         return 0 /* LDKPaymentSendFailure - PartialFailure */;
2259                 }
2260                 default: abort();
2261         }
2262 }
2263 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2264         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2265 }
2266 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2267         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2268         CHECK(val->result_ok);
2269         return *val->contents.result;
2270 }
2271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2272         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2273         CHECK(!val->result_ok);
2274         long err_ref = ((long)&(*val->contents.err)) | 1;
2275         return err_ref;
2276 }
2277 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2278         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2279         ret->datalen = *((uint32_t*)elems);
2280         if (ret->datalen == 0) {
2281                 ret->data = NULL;
2282         } else {
2283                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2284                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2285                 for (size_t i = 0; i < ret->datalen; i++) {
2286                         uint32_t arr_elem = java_elems[i];
2287                         LDKChannelMonitor arr_elem_conv;
2288                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2289                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2290                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2291                         ret->data[i] = arr_elem_conv;
2292                 }
2293         }
2294         return (long)ret;
2295 }
2296 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2297         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2298         for (size_t i = 0; i < ret.datalen; i++) {
2299                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2300         }
2301         return ret;
2302 }
2303 typedef struct LDKWatch_JCalls {
2304         atomic_size_t refcnt;
2305         uint32_t watch_channel_meth;
2306         uint32_t update_channel_meth;
2307         uint32_t release_pending_monitor_events_meth;
2308 } LDKWatch_JCalls;
2309 static void LDKWatch_JCalls_free(void* this_arg) {
2310         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2311         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2312                 js_free(j_calls->watch_channel_meth);
2313                 js_free(j_calls->update_channel_meth);
2314                 js_free(j_calls->release_pending_monitor_events_meth);
2315                 FREE(j_calls);
2316         }
2317 }
2318 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2319         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2320         LDKOutPoint funding_txo_var = funding_txo;
2321         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2322         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2323         long funding_txo_ref = (long)funding_txo_var.inner;
2324         if (funding_txo_var.is_owned) {
2325                 funding_txo_ref |= 1;
2326         }
2327         LDKChannelMonitor monitor_var = monitor;
2328         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2329         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2330         long monitor_ref = (long)monitor_var.inner;
2331         if (monitor_var.is_owned) {
2332                 monitor_ref |= 1;
2333         }
2334         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2335         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2336         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2337         return ret_conv;
2338 }
2339 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2340         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2341         LDKOutPoint funding_txo_var = funding_txo;
2342         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2343         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2344         long funding_txo_ref = (long)funding_txo_var.inner;
2345         if (funding_txo_var.is_owned) {
2346                 funding_txo_ref |= 1;
2347         }
2348         LDKChannelMonitorUpdate update_var = update;
2349         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2350         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2351         long update_ref = (long)update_var.inner;
2352         if (update_var.is_owned) {
2353                 update_ref |= 1;
2354         }
2355         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2356         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2357         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2358         return ret_conv;
2359 }
2360 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2361         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2362         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2363         LDKCVec_MonitorEventZ ret_constr;
2364         ret_constr.datalen = *((uint32_t*)ret);
2365         if (ret_constr.datalen > 0)
2366                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2367         else
2368                 ret_constr.data = NULL;
2369         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2370         for (size_t o = 0; o < ret_constr.datalen; o++) {
2371                 uint32_t ret_conv_14 = ret_vals[o];
2372                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2373                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)ret_conv_14);
2374                 ret_constr.data[o] = ret_conv_14_conv;
2375         }
2376         return ret_constr;
2377 }
2378 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2379         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2380         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2381         return (void*) this_arg;
2382 }
2383 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2384         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2385         atomic_init(&calls->refcnt, 1);
2386         //TODO: Assign calls->o from o
2387
2388         LDKWatch ret = {
2389                 .this_arg = (void*) calls,
2390                 .watch_channel = watch_channel_jcall,
2391                 .update_channel = update_channel_jcall,
2392                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2393                 .free = LDKWatch_JCalls_free,
2394         };
2395         return ret;
2396 }
2397 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2398         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2399         *res_ptr = LDKWatch_init(o);
2400         return (long)res_ptr;
2401 }
2402 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2403         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2404         LDKOutPoint funding_txo_conv;
2405         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2406         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2407         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2408         LDKChannelMonitor monitor_conv;
2409         monitor_conv.inner = (void*)(monitor & (~1));
2410         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2411         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2412         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2413         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2414         return (long)ret_conv;
2415 }
2416
2417 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2418         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2419         LDKOutPoint funding_txo_conv;
2420         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2421         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2422         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2423         LDKChannelMonitorUpdate update_conv;
2424         update_conv.inner = (void*)(update & (~1));
2425         update_conv.is_owned = (update & 1) || (update == 0);
2426         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2427         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2428         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2429         return (long)ret_conv;
2430 }
2431
2432 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2433         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2434         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2435         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2436         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2437         for (size_t o = 0; o < ret_var.datalen; o++) {
2438                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2439                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2440                 long ret_conv_14_ref = (long)ret_conv_14_copy;
2441                 ret_arr_ptr[o] = ret_conv_14_ref;
2442         }
2443         FREE(ret_var.data);
2444         return ret_arr;
2445 }
2446
2447 typedef struct LDKBroadcasterInterface_JCalls {
2448         atomic_size_t refcnt;
2449         uint32_t broadcast_transaction_meth;
2450 } LDKBroadcasterInterface_JCalls;
2451 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2452         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2453         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2454                 js_free(j_calls->broadcast_transaction_meth);
2455                 FREE(j_calls);
2456         }
2457 }
2458 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2459         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2460         LDKTransaction tx_var = tx;
2461         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2462         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2463         Transaction_free(tx_var);
2464         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2465 }
2466 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2467         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2468         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2469         return (void*) this_arg;
2470 }
2471 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2472         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2473         atomic_init(&calls->refcnt, 1);
2474         //TODO: Assign calls->o from o
2475
2476         LDKBroadcasterInterface ret = {
2477                 .this_arg = (void*) calls,
2478                 .broadcast_transaction = broadcast_transaction_jcall,
2479                 .free = LDKBroadcasterInterface_JCalls_free,
2480         };
2481         return ret;
2482 }
2483 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2484         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2485         *res_ptr = LDKBroadcasterInterface_init(o);
2486         return (long)res_ptr;
2487 }
2488 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2489         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2490         LDKTransaction tx_ref;
2491         tx_ref.datalen = *((uint32_t*)tx);
2492         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2493         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2494         tx_ref.data_is_owned = true;
2495         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2496 }
2497
2498 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
2499         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2500 }
2501 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2502         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2503         CHECK(val->result_ok);
2504         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2505         *ret = Sign_clone(&(*val->contents.result));
2506         return (long)ret;
2507 }
2508 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2509         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2510         CHECK(!val->result_ok);
2511         LDKDecodeError err_var = (*val->contents.err);
2512         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2513         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2514         long err_ref = (long)err_var.inner & ~1;
2515         return err_ref;
2516 }
2517 typedef struct LDKKeysInterface_JCalls {
2518         atomic_size_t refcnt;
2519         uint32_t get_node_secret_meth;
2520         uint32_t get_destination_script_meth;
2521         uint32_t get_shutdown_pubkey_meth;
2522         uint32_t get_channel_signer_meth;
2523         uint32_t get_secure_random_bytes_meth;
2524         uint32_t read_chan_signer_meth;
2525 } LDKKeysInterface_JCalls;
2526 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2527         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2528         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2529                 js_free(j_calls->get_node_secret_meth);
2530                 js_free(j_calls->get_destination_script_meth);
2531                 js_free(j_calls->get_shutdown_pubkey_meth);
2532                 js_free(j_calls->get_channel_signer_meth);
2533                 js_free(j_calls->get_secure_random_bytes_meth);
2534                 js_free(j_calls->read_chan_signer_meth);
2535                 FREE(j_calls);
2536         }
2537 }
2538 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2539         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2540         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2541         LDKSecretKey ret_ref;
2542         CHECK(*((uint32_t*)ret) == 32);
2543         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2544         return ret_ref;
2545 }
2546 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2547         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2548         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2549         LDKCVec_u8Z ret_ref;
2550         ret_ref.datalen = *((uint32_t*)ret);
2551         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2552         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2553         return ret_ref;
2554 }
2555 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2556         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2557         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2558         LDKPublicKey ret_ref;
2559         CHECK(*((uint32_t*)ret) == 33);
2560         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2561         return ret_ref;
2562 }
2563 LDKSign get_channel_signer_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2564         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2565         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2566         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2567         ret_conv = Sign_clone(ret);
2568         return ret_conv;
2569 }
2570 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2571         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2572         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2573         LDKThirtyTwoBytes ret_ref;
2574         CHECK(*((uint32_t*)ret) == 32);
2575         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2576         return ret_ref;
2577 }
2578 LDKCResult_SignDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
2579         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2580         LDKu8slice reader_var = reader;
2581         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2582         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2583         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2584         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2585         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)ret);
2586         return ret_conv;
2587 }
2588 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2589         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2591         return (void*) this_arg;
2592 }
2593 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2594         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2595         atomic_init(&calls->refcnt, 1);
2596         //TODO: Assign calls->o from o
2597
2598         LDKKeysInterface ret = {
2599                 .this_arg = (void*) calls,
2600                 .get_node_secret = get_node_secret_jcall,
2601                 .get_destination_script = get_destination_script_jcall,
2602                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2603                 .get_channel_signer = get_channel_signer_jcall,
2604                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2605                 .read_chan_signer = read_chan_signer_jcall,
2606                 .free = LDKKeysInterface_JCalls_free,
2607         };
2608         return ret;
2609 }
2610 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2611         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2612         *res_ptr = LDKKeysInterface_init(o);
2613         return (long)res_ptr;
2614 }
2615 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2616         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2617         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2618         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2619         return ret_arr;
2620 }
2621
2622 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2623         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2624         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2625         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2626         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2627         CVec_u8Z_free(ret_var);
2628         return ret_arr;
2629 }
2630
2631 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2632         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2633         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2634         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2635         return ret_arr;
2636 }
2637
2638 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2639         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2640         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2641         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2642         return (long)ret;
2643 }
2644
2645 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2646         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2647         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2648         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2649         return ret_arr;
2650 }
2651
2652 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2653         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2654         LDKu8slice reader_ref;
2655         reader_ref.datalen = *((uint32_t*)reader);
2656         reader_ref.data = (int8_t*)(reader + 4);
2657         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2658         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2659         return (long)ret_conv;
2660 }
2661
2662 typedef struct LDKFeeEstimator_JCalls {
2663         atomic_size_t refcnt;
2664         uint32_t get_est_sat_per_1000_weight_meth;
2665 } LDKFeeEstimator_JCalls;
2666 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2667         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2668         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2669                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2670                 FREE(j_calls);
2671         }
2672 }
2673 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2674         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2675         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2676         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2677 }
2678 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2679         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2680         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2681         return (void*) this_arg;
2682 }
2683 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2684         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2685         atomic_init(&calls->refcnt, 1);
2686         //TODO: Assign calls->o from o
2687
2688         LDKFeeEstimator ret = {
2689                 .this_arg = (void*) calls,
2690                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2691                 .free = LDKFeeEstimator_JCalls_free,
2692         };
2693         return ret;
2694 }
2695 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2696         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2697         *res_ptr = LDKFeeEstimator_init(o);
2698         return (long)res_ptr;
2699 }
2700 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2701         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2702         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2703         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2704         return ret_val;
2705 }
2706
2707 typedef struct LDKLogger_JCalls {
2708         atomic_size_t refcnt;
2709         uint32_t log_meth;
2710 } LDKLogger_JCalls;
2711 static void LDKLogger_JCalls_free(void* this_arg) {
2712         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2713         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2714                 js_free(j_calls->log_meth);
2715                 FREE(j_calls);
2716         }
2717 }
2718 void log_jcall(const void* this_arg, const char* record) {
2719         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2720         const char* record_str = record;
2721         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2722         js_invoke_function_1(j_calls->log_meth, record_conv);
2723 }
2724 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2725         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2726         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2727         return (void*) this_arg;
2728 }
2729 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2730         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2731         atomic_init(&calls->refcnt, 1);
2732         //TODO: Assign calls->o from o
2733
2734         LDKLogger ret = {
2735                 .this_arg = (void*) calls,
2736                 .log = log_jcall,
2737                 .free = LDKLogger_JCalls_free,
2738         };
2739         return ret;
2740 }
2741 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2742         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2743         *res_ptr = LDKLogger_init(o);
2744         return (long)res_ptr;
2745 }
2746 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2747         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2748         LDKThirtyTwoBytes a_ref;
2749         CHECK(*((uint32_t*)a) == 32);
2750         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2751         ret->a = a_ref;
2752         LDKChannelManager b_conv;
2753         b_conv.inner = (void*)(b & (~1));
2754         b_conv.is_owned = (b & 1) || (b == 0);
2755         // Warning: we need a move here but no clone is available for LDKChannelManager
2756         ret->b = b_conv;
2757         return (long)ret;
2758 }
2759 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2760         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2761         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2762         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2763         return a_arr;
2764 }
2765 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2766         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2767         LDKChannelManager b_var = tuple->b;
2768         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2769         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2770         long b_ref = (long)b_var.inner & ~1;
2771         return b_ref;
2772 }
2773 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2774         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2775 }
2776 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2777         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2778         CHECK(val->result_ok);
2779         long res_ref = (long)(&(*val->contents.result)) | 1;
2780         return res_ref;
2781 }
2782 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2783         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2784         CHECK(!val->result_ok);
2785         LDKDecodeError err_var = (*val->contents.err);
2786         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2787         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2788         long err_ref = (long)err_var.inner & ~1;
2789         return err_ref;
2790 }
2791 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
2792         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2793 }
2794 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
2795         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2796         CHECK(val->result_ok);
2797         long res_ref = ((long)&(*val->contents.result)) | 1;
2798         return res_ref;
2799 }
2800 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
2801         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2802         CHECK(!val->result_ok);
2803         LDKDecodeError err_var = (*val->contents.err);
2804         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2805         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2806         long err_ref = (long)err_var.inner & ~1;
2807         return err_ref;
2808 }
2809 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2810         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2811         for (size_t i = 0; i < ret.datalen; i++) {
2812                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2813         }
2814         return ret;
2815 }
2816 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2817         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2818 }
2819 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2820         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2821         CHECK(val->result_ok);
2822         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2823         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2824         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2825         for (size_t m = 0; m < res_var.datalen; m++) {
2826                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2827                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2828                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2829                 res_arr_ptr[m] = res_conv_12_arr;
2830         }
2831         return res_arr;
2832 }
2833 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2834         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2835         CHECK(!val->result_ok);
2836         return *val->contents.err;
2837 }
2838 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2839         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2840 }
2841 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2842         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2843         CHECK(val->result_ok);
2844         LDKInMemorySigner res_var = (*val->contents.result);
2845         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2846         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2847         long res_ref = (long)res_var.inner & ~1;
2848         return res_ref;
2849 }
2850 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2851         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2852         CHECK(!val->result_ok);
2853         LDKDecodeError err_var = (*val->contents.err);
2854         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2855         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2856         long err_ref = (long)err_var.inner & ~1;
2857         return err_ref;
2858 }
2859 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2860         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2861         ret->datalen = *((uint32_t*)elems);
2862         if (ret->datalen == 0) {
2863                 ret->data = NULL;
2864         } else {
2865                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2866                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2867                 for (size_t i = 0; i < ret->datalen; i++) {
2868                         uint32_t arr_elem = java_elems[i];
2869                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2870                         FREE((void*)arr_elem);
2871                         ret->data[i] = arr_elem_conv;
2872                 }
2873         }
2874         return (long)ret;
2875 }
2876 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2877         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2878         for (size_t i = 0; i < ret.datalen; i++) {
2879                 ret.data[i] = TxOut_clone(&orig->data[i]);
2880         }
2881         return ret;
2882 }
2883 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2884         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2885 }
2886 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2887         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2888         CHECK(val->result_ok);
2889         LDKTransaction res_var = (*val->contents.result);
2890         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2891         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2892         return res_arr;
2893 }
2894 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2895         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2896         CHECK(!val->result_ok);
2897         return *val->contents.err;
2898 }
2899 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
2900         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2901         ret->datalen = *((uint32_t*)elems);
2902         if (ret->datalen == 0) {
2903                 ret->data = NULL;
2904         } else {
2905                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2906                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2907                 for (size_t i = 0; i < ret->datalen; i++) {
2908                         uint32_t arr_elem = java_elems[i];
2909                         LDKRouteHop arr_elem_conv;
2910                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2911                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2912                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2913                         ret->data[i] = arr_elem_conv;
2914                 }
2915         }
2916         return (long)ret;
2917 }
2918 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2919         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2920         for (size_t i = 0; i < ret.datalen; i++) {
2921                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2922         }
2923         return ret;
2924 }
2925 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2926         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2927         for (size_t i = 0; i < ret.datalen; i++) {
2928                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2929         }
2930         return ret;
2931 }
2932 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
2933         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2934 }
2935 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
2936         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2937         CHECK(val->result_ok);
2938         LDKRoute res_var = (*val->contents.result);
2939         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2940         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2941         long res_ref = (long)res_var.inner & ~1;
2942         return res_ref;
2943 }
2944 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
2945         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2946         CHECK(!val->result_ok);
2947         LDKDecodeError err_var = (*val->contents.err);
2948         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2949         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2950         long err_ref = (long)err_var.inner & ~1;
2951         return err_ref;
2952 }
2953 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
2954         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2955         ret->datalen = *((uint32_t*)elems);
2956         if (ret->datalen == 0) {
2957                 ret->data = NULL;
2958         } else {
2959                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2960                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2961                 for (size_t i = 0; i < ret->datalen; i++) {
2962                         uint32_t arr_elem = java_elems[i];
2963                         LDKRouteHint arr_elem_conv;
2964                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2965                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2966                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2967                         ret->data[i] = arr_elem_conv;
2968                 }
2969         }
2970         return (long)ret;
2971 }
2972 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2973         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2974         for (size_t i = 0; i < ret.datalen; i++) {
2975                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2976         }
2977         return ret;
2978 }
2979 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
2980         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2981 }
2982 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
2983         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2984         CHECK(val->result_ok);
2985         LDKRoute res_var = (*val->contents.result);
2986         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2987         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2988         long res_ref = (long)res_var.inner & ~1;
2989         return res_ref;
2990 }
2991 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
2992         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2993         CHECK(!val->result_ok);
2994         LDKLightningError err_var = (*val->contents.err);
2995         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2996         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2997         long err_ref = (long)err_var.inner & ~1;
2998         return err_ref;
2999 }
3000 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3001         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3002 }
3003 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3004         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3005         CHECK(val->result_ok);
3006         long res_ref = ((long)&(*val->contents.result)) | 1;
3007         return res_ref;
3008 }
3009 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3010         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3011         CHECK(!val->result_ok);
3012         return *val->contents.err;
3013 }
3014 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3015         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3016 }
3017 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3018         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3019         CHECK(val->result_ok);
3020         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3021         *res_conv = (*val->contents.result);
3022         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3023         return (long)res_conv;
3024 }
3025 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3026         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3027         CHECK(!val->result_ok);
3028         LDKDecodeError err_var = (*val->contents.err);
3029         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3030         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3031         long err_ref = (long)err_var.inner & ~1;
3032         return err_ref;
3033 }
3034 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3035         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3036         ret->datalen = *((uint32_t*)elems);
3037         if (ret->datalen == 0) {
3038                 ret->data = NULL;
3039         } else {
3040                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3041                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3042                 for (size_t i = 0; i < ret->datalen; i++) {
3043                         uint32_t arr_elem = java_elems[i];
3044                         LDKUpdateAddHTLC arr_elem_conv;
3045                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3046                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3047                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3048                         ret->data[i] = arr_elem_conv;
3049                 }
3050         }
3051         return (long)ret;
3052 }
3053 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3054         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3055         for (size_t i = 0; i < ret.datalen; i++) {
3056                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3057         }
3058         return ret;
3059 }
3060 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3061         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3062         ret->datalen = *((uint32_t*)elems);
3063         if (ret->datalen == 0) {
3064                 ret->data = NULL;
3065         } else {
3066                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3067                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3068                 for (size_t i = 0; i < ret->datalen; i++) {
3069                         uint32_t arr_elem = java_elems[i];
3070                         LDKUpdateFulfillHTLC arr_elem_conv;
3071                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3072                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3073                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3074                         ret->data[i] = arr_elem_conv;
3075                 }
3076         }
3077         return (long)ret;
3078 }
3079 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3080         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3081         for (size_t i = 0; i < ret.datalen; i++) {
3082                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3083         }
3084         return ret;
3085 }
3086 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3087         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3088         ret->datalen = *((uint32_t*)elems);
3089         if (ret->datalen == 0) {
3090                 ret->data = NULL;
3091         } else {
3092                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3093                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3094                 for (size_t i = 0; i < ret->datalen; i++) {
3095                         uint32_t arr_elem = java_elems[i];
3096                         LDKUpdateFailHTLC arr_elem_conv;
3097                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3098                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3099                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3100                         ret->data[i] = arr_elem_conv;
3101                 }
3102         }
3103         return (long)ret;
3104 }
3105 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3106         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3107         for (size_t i = 0; i < ret.datalen; i++) {
3108                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3109         }
3110         return ret;
3111 }
3112 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3113         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3114         ret->datalen = *((uint32_t*)elems);
3115         if (ret->datalen == 0) {
3116                 ret->data = NULL;
3117         } else {
3118                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3119                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3120                 for (size_t i = 0; i < ret->datalen; i++) {
3121                         uint32_t arr_elem = java_elems[i];
3122                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3123                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3124                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3125                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3126                         ret->data[i] = arr_elem_conv;
3127                 }
3128         }
3129         return (long)ret;
3130 }
3131 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3132         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3133         for (size_t i = 0; i < ret.datalen; i++) {
3134                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3135         }
3136         return ret;
3137 }
3138 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3139         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3140 }
3141 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3142         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3143         CHECK(val->result_ok);
3144         LDKAcceptChannel res_var = (*val->contents.result);
3145         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3146         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3147         long res_ref = (long)res_var.inner & ~1;
3148         return res_ref;
3149 }
3150 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3151         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3152         CHECK(!val->result_ok);
3153         LDKDecodeError err_var = (*val->contents.err);
3154         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3155         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3156         long err_ref = (long)err_var.inner & ~1;
3157         return err_ref;
3158 }
3159 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3160         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3161 }
3162 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3163         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3164         CHECK(val->result_ok);
3165         LDKAnnouncementSignatures res_var = (*val->contents.result);
3166         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3167         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3168         long res_ref = (long)res_var.inner & ~1;
3169         return res_ref;
3170 }
3171 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3172         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3173         CHECK(!val->result_ok);
3174         LDKDecodeError err_var = (*val->contents.err);
3175         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3176         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3177         long err_ref = (long)err_var.inner & ~1;
3178         return err_ref;
3179 }
3180 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
3181         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3182 }
3183 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
3184         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3185         CHECK(val->result_ok);
3186         LDKChannelReestablish res_var = (*val->contents.result);
3187         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3188         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3189         long res_ref = (long)res_var.inner & ~1;
3190         return res_ref;
3191 }
3192 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
3193         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3194         CHECK(!val->result_ok);
3195         LDKDecodeError err_var = (*val->contents.err);
3196         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3197         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3198         long err_ref = (long)err_var.inner & ~1;
3199         return err_ref;
3200 }
3201 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3202         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3203 }
3204 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3205         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3206         CHECK(val->result_ok);
3207         LDKClosingSigned res_var = (*val->contents.result);
3208         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3209         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3210         long res_ref = (long)res_var.inner & ~1;
3211         return res_ref;
3212 }
3213 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
3214         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3215         CHECK(!val->result_ok);
3216         LDKDecodeError err_var = (*val->contents.err);
3217         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3218         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3219         long err_ref = (long)err_var.inner & ~1;
3220         return err_ref;
3221 }
3222 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
3223         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3224 }
3225 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
3226         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3227         CHECK(val->result_ok);
3228         LDKCommitmentSigned res_var = (*val->contents.result);
3229         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3230         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3231         long res_ref = (long)res_var.inner & ~1;
3232         return res_ref;
3233 }
3234 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
3235         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3236         CHECK(!val->result_ok);
3237         LDKDecodeError err_var = (*val->contents.err);
3238         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3239         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3240         long err_ref = (long)err_var.inner & ~1;
3241         return err_ref;
3242 }
3243 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
3244         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3245 }
3246 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
3247         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3248         CHECK(val->result_ok);
3249         LDKFundingCreated res_var = (*val->contents.result);
3250         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3251         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3252         long res_ref = (long)res_var.inner & ~1;
3253         return res_ref;
3254 }
3255 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
3256         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3257         CHECK(!val->result_ok);
3258         LDKDecodeError err_var = (*val->contents.err);
3259         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3260         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3261         long err_ref = (long)err_var.inner & ~1;
3262         return err_ref;
3263 }
3264 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3265         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3266 }
3267 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3268         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3269         CHECK(val->result_ok);
3270         LDKFundingSigned res_var = (*val->contents.result);
3271         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3272         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3273         long res_ref = (long)res_var.inner & ~1;
3274         return res_ref;
3275 }
3276 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
3277         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3278         CHECK(!val->result_ok);
3279         LDKDecodeError err_var = (*val->contents.err);
3280         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3281         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3282         long err_ref = (long)err_var.inner & ~1;
3283         return err_ref;
3284 }
3285 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
3286         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3287 }
3288 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
3289         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3290         CHECK(val->result_ok);
3291         LDKFundingLocked res_var = (*val->contents.result);
3292         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3293         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3294         long res_ref = (long)res_var.inner & ~1;
3295         return res_ref;
3296 }
3297 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
3298         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3299         CHECK(!val->result_ok);
3300         LDKDecodeError err_var = (*val->contents.err);
3301         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3302         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3303         long err_ref = (long)err_var.inner & ~1;
3304         return err_ref;
3305 }
3306 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
3307         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3308 }
3309 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
3310         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3311         CHECK(val->result_ok);
3312         LDKInit res_var = (*val->contents.result);
3313         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3314         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3315         long res_ref = (long)res_var.inner & ~1;
3316         return res_ref;
3317 }
3318 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
3319         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3320         CHECK(!val->result_ok);
3321         LDKDecodeError err_var = (*val->contents.err);
3322         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3323         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3324         long err_ref = (long)err_var.inner & ~1;
3325         return err_ref;
3326 }
3327 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
3328         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3329 }
3330 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
3331         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3332         CHECK(val->result_ok);
3333         LDKOpenChannel res_var = (*val->contents.result);
3334         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3335         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3336         long res_ref = (long)res_var.inner & ~1;
3337         return res_ref;
3338 }
3339 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
3340         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3341         CHECK(!val->result_ok);
3342         LDKDecodeError err_var = (*val->contents.err);
3343         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3344         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3345         long err_ref = (long)err_var.inner & ~1;
3346         return err_ref;
3347 }
3348 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
3349         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3350 }
3351 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
3352         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3353         CHECK(val->result_ok);
3354         LDKRevokeAndACK res_var = (*val->contents.result);
3355         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3356         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3357         long res_ref = (long)res_var.inner & ~1;
3358         return res_ref;
3359 }
3360 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
3361         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3362         CHECK(!val->result_ok);
3363         LDKDecodeError err_var = (*val->contents.err);
3364         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3365         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3366         long err_ref = (long)err_var.inner & ~1;
3367         return err_ref;
3368 }
3369 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
3370         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3371 }
3372 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
3373         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3374         CHECK(val->result_ok);
3375         LDKShutdown res_var = (*val->contents.result);
3376         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3377         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3378         long res_ref = (long)res_var.inner & ~1;
3379         return res_ref;
3380 }
3381 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
3382         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3383         CHECK(!val->result_ok);
3384         LDKDecodeError err_var = (*val->contents.err);
3385         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3386         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3387         long err_ref = (long)err_var.inner & ~1;
3388         return err_ref;
3389 }
3390 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3391         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3392 }
3393 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3394         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3395         CHECK(val->result_ok);
3396         LDKUpdateFailHTLC res_var = (*val->contents.result);
3397         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3398         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3399         long res_ref = (long)res_var.inner & ~1;
3400         return res_ref;
3401 }
3402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
3403         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3404         CHECK(!val->result_ok);
3405         LDKDecodeError err_var = (*val->contents.err);
3406         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3407         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3408         long err_ref = (long)err_var.inner & ~1;
3409         return err_ref;
3410 }
3411 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3412         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3413 }
3414 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3415         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3416         CHECK(val->result_ok);
3417         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
3418         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3419         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3420         long res_ref = (long)res_var.inner & ~1;
3421         return res_ref;
3422 }
3423 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
3424         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3425         CHECK(!val->result_ok);
3426         LDKDecodeError err_var = (*val->contents.err);
3427         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3428         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3429         long err_ref = (long)err_var.inner & ~1;
3430         return err_ref;
3431 }
3432 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
3433         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3434 }
3435 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
3436         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3437         CHECK(val->result_ok);
3438         LDKUpdateFee res_var = (*val->contents.result);
3439         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         long res_ref = (long)res_var.inner & ~1;
3442         return res_ref;
3443 }
3444 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
3445         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3446         CHECK(!val->result_ok);
3447         LDKDecodeError err_var = (*val->contents.err);
3448         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3449         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3450         long err_ref = (long)err_var.inner & ~1;
3451         return err_ref;
3452 }
3453 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3454         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3455 }
3456 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3457         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3458         CHECK(val->result_ok);
3459         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
3460         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3461         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3462         long res_ref = (long)res_var.inner & ~1;
3463         return res_ref;
3464 }
3465 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
3466         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3467         CHECK(!val->result_ok);
3468         LDKDecodeError err_var = (*val->contents.err);
3469         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3470         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3471         long err_ref = (long)err_var.inner & ~1;
3472         return err_ref;
3473 }
3474 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3475         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3476 }
3477 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3478         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3479         CHECK(val->result_ok);
3480         LDKUpdateAddHTLC res_var = (*val->contents.result);
3481         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3482         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3483         long res_ref = (long)res_var.inner & ~1;
3484         return res_ref;
3485 }
3486 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
3487         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3488         CHECK(!val->result_ok);
3489         LDKDecodeError err_var = (*val->contents.err);
3490         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3491         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3492         long err_ref = (long)err_var.inner & ~1;
3493         return err_ref;
3494 }
3495 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
3496         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3497 }
3498 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
3499         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3500         CHECK(val->result_ok);
3501         LDKPing res_var = (*val->contents.result);
3502         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3503         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3504         long res_ref = (long)res_var.inner & ~1;
3505         return res_ref;
3506 }
3507 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
3508         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3509         CHECK(!val->result_ok);
3510         LDKDecodeError err_var = (*val->contents.err);
3511         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3512         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3513         long err_ref = (long)err_var.inner & ~1;
3514         return err_ref;
3515 }
3516 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
3517         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
3518 }
3519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
3520         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3521         CHECK(val->result_ok);
3522         LDKPong res_var = (*val->contents.result);
3523         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3524         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3525         long res_ref = (long)res_var.inner & ~1;
3526         return res_ref;
3527 }
3528 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
3529         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3530         CHECK(!val->result_ok);
3531         LDKDecodeError err_var = (*val->contents.err);
3532         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3533         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3534         long err_ref = (long)err_var.inner & ~1;
3535         return err_ref;
3536 }
3537 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3538         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3539 }
3540 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3541         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3542         CHECK(val->result_ok);
3543         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
3544         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         long res_ref = (long)res_var.inner & ~1;
3547         return res_ref;
3548 }
3549 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3550         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3551         CHECK(!val->result_ok);
3552         LDKDecodeError err_var = (*val->contents.err);
3553         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3554         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3555         long err_ref = (long)err_var.inner & ~1;
3556         return err_ref;
3557 }
3558 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3559         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3560 }
3561 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3562         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3563         CHECK(val->result_ok);
3564         LDKChannelAnnouncement res_var = (*val->contents.result);
3565         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3566         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3567         long res_ref = (long)res_var.inner & ~1;
3568         return res_ref;
3569 }
3570 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3571         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3572         CHECK(!val->result_ok);
3573         LDKDecodeError err_var = (*val->contents.err);
3574         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3575         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3576         long err_ref = (long)err_var.inner & ~1;
3577         return err_ref;
3578 }
3579 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3580         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
3581 }
3582 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3583         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3584         CHECK(val->result_ok);
3585         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
3586         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3587         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3588         long res_ref = (long)res_var.inner & ~1;
3589         return res_ref;
3590 }
3591 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3592         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3593         CHECK(!val->result_ok);
3594         LDKDecodeError err_var = (*val->contents.err);
3595         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3596         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3597         long err_ref = (long)err_var.inner & ~1;
3598         return err_ref;
3599 }
3600 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3601         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3602 }
3603 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3604         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3605         CHECK(val->result_ok);
3606         LDKChannelUpdate res_var = (*val->contents.result);
3607         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3608         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3609         long res_ref = (long)res_var.inner & ~1;
3610         return res_ref;
3611 }
3612 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3613         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3614         CHECK(!val->result_ok);
3615         LDKDecodeError err_var = (*val->contents.err);
3616         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3617         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3618         long err_ref = (long)err_var.inner & ~1;
3619         return err_ref;
3620 }
3621 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
3622         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3623 }
3624 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
3625         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3626         CHECK(val->result_ok);
3627         LDKErrorMessage res_var = (*val->contents.result);
3628         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3629         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3630         long res_ref = (long)res_var.inner & ~1;
3631         return res_ref;
3632 }
3633 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
3634         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3635         CHECK(!val->result_ok);
3636         LDKDecodeError err_var = (*val->contents.err);
3637         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3638         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3639         long err_ref = (long)err_var.inner & ~1;
3640         return err_ref;
3641 }
3642 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3643         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3644 }
3645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3646         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3647         CHECK(val->result_ok);
3648         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
3649         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3650         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3651         long res_ref = (long)res_var.inner & ~1;
3652         return res_ref;
3653 }
3654 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3655         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3656         CHECK(!val->result_ok);
3657         LDKDecodeError err_var = (*val->contents.err);
3658         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3659         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3660         long err_ref = (long)err_var.inner & ~1;
3661         return err_ref;
3662 }
3663 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3664         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3665 }
3666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3667         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3668         CHECK(val->result_ok);
3669         LDKNodeAnnouncement res_var = (*val->contents.result);
3670         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3671         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3672         long res_ref = (long)res_var.inner & ~1;
3673         return res_ref;
3674 }
3675 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3676         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3677         CHECK(!val->result_ok);
3678         LDKDecodeError err_var = (*val->contents.err);
3679         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3680         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3681         long err_ref = (long)err_var.inner & ~1;
3682         return err_ref;
3683 }
3684 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
3685         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3686 }
3687 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
3688         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3689         CHECK(val->result_ok);
3690         LDKQueryShortChannelIds res_var = (*val->contents.result);
3691         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3692         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3693         long res_ref = (long)res_var.inner & ~1;
3694         return res_ref;
3695 }
3696 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
3697         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3698         CHECK(!val->result_ok);
3699         LDKDecodeError err_var = (*val->contents.err);
3700         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3701         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3702         long err_ref = (long)err_var.inner & ~1;
3703         return err_ref;
3704 }
3705 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
3706         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3707 }
3708 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
3709         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3710         CHECK(val->result_ok);
3711         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
3712         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3713         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3714         long res_ref = (long)res_var.inner & ~1;
3715         return res_ref;
3716 }
3717 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
3718         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3719         CHECK(!val->result_ok);
3720         LDKDecodeError err_var = (*val->contents.err);
3721         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3722         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3723         long err_ref = (long)err_var.inner & ~1;
3724         return err_ref;
3725 }
3726 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3727         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3728 }
3729 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3730         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3731         CHECK(val->result_ok);
3732         LDKQueryChannelRange res_var = (*val->contents.result);
3733         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3734         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3735         long res_ref = (long)res_var.inner & ~1;
3736         return res_ref;
3737 }
3738 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3739         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3740         CHECK(!val->result_ok);
3741         LDKDecodeError err_var = (*val->contents.err);
3742         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3743         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3744         long err_ref = (long)err_var.inner & ~1;
3745         return err_ref;
3746 }
3747 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3748         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3749 }
3750 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3751         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3752         CHECK(val->result_ok);
3753         LDKReplyChannelRange res_var = (*val->contents.result);
3754         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3755         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3756         long res_ref = (long)res_var.inner & ~1;
3757         return res_ref;
3758 }
3759 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3760         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3761         CHECK(!val->result_ok);
3762         LDKDecodeError err_var = (*val->contents.err);
3763         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3764         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3765         long err_ref = (long)err_var.inner & ~1;
3766         return err_ref;
3767 }
3768 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
3769         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3770 }
3771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
3772         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3773         CHECK(val->result_ok);
3774         LDKGossipTimestampFilter res_var = (*val->contents.result);
3775         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3776         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3777         long res_ref = (long)res_var.inner & ~1;
3778         return res_ref;
3779 }
3780 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
3781         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3782         CHECK(!val->result_ok);
3783         LDKDecodeError err_var = (*val->contents.err);
3784         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3785         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3786         long err_ref = (long)err_var.inner & ~1;
3787         return err_ref;
3788 }
3789 typedef struct LDKMessageSendEventsProvider_JCalls {
3790         atomic_size_t refcnt;
3791         uint32_t get_and_clear_pending_msg_events_meth;
3792 } LDKMessageSendEventsProvider_JCalls;
3793 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
3794         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3796                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
3797                 FREE(j_calls);
3798         }
3799 }
3800 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
3801         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3802         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
3803         LDKCVec_MessageSendEventZ ret_constr;
3804         ret_constr.datalen = *((uint32_t*)ret);
3805         if (ret_constr.datalen > 0)
3806                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3807         else
3808                 ret_constr.data = NULL;
3809         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3810         for (size_t s = 0; s < ret_constr.datalen; s++) {
3811                 uint32_t ret_conv_18 = ret_vals[s];
3812                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
3813                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)ret_conv_18);
3814                 ret_constr.data[s] = ret_conv_18_conv;
3815         }
3816         return ret_constr;
3817 }
3818 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
3819         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3820         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3821         return (void*) this_arg;
3822 }
3823 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3824         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
3825         atomic_init(&calls->refcnt, 1);
3826         //TODO: Assign calls->o from o
3827
3828         LDKMessageSendEventsProvider ret = {
3829                 .this_arg = (void*) calls,
3830                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
3831                 .free = LDKMessageSendEventsProvider_JCalls_free,
3832         };
3833         return ret;
3834 }
3835 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3836         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
3837         *res_ptr = LDKMessageSendEventsProvider_init(o);
3838         return (long)res_ptr;
3839 }
3840 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
3841         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
3842         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
3843         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3844         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3845         for (size_t s = 0; s < ret_var.datalen; s++) {
3846                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
3847                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
3848                 long ret_conv_18_ref = (long)ret_conv_18_copy;
3849                 ret_arr_ptr[s] = ret_conv_18_ref;
3850         }
3851         FREE(ret_var.data);
3852         return ret_arr;
3853 }
3854
3855 typedef struct LDKEventsProvider_JCalls {
3856         atomic_size_t refcnt;
3857         uint32_t get_and_clear_pending_events_meth;
3858 } LDKEventsProvider_JCalls;
3859 static void LDKEventsProvider_JCalls_free(void* this_arg) {
3860         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3861         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3862                 js_free(j_calls->get_and_clear_pending_events_meth);
3863                 FREE(j_calls);
3864         }
3865 }
3866 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
3867         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3868         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
3869         LDKCVec_EventZ ret_constr;
3870         ret_constr.datalen = *((uint32_t*)ret);
3871         if (ret_constr.datalen > 0)
3872                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3873         else
3874                 ret_constr.data = NULL;
3875         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3876         for (size_t h = 0; h < ret_constr.datalen; h++) {
3877                 uint32_t ret_conv_7 = ret_vals[h];
3878                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
3879                 ret_conv_7_conv = Event_clone((LDKEvent*)ret_conv_7);
3880                 ret_constr.data[h] = ret_conv_7_conv;
3881         }
3882         return ret_constr;
3883 }
3884 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
3885         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3886         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3887         return (void*) this_arg;
3888 }
3889 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3890         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
3891         atomic_init(&calls->refcnt, 1);
3892         //TODO: Assign calls->o from o
3893
3894         LDKEventsProvider ret = {
3895                 .this_arg = (void*) calls,
3896                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
3897                 .free = LDKEventsProvider_JCalls_free,
3898         };
3899         return ret;
3900 }
3901 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3902         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
3903         *res_ptr = LDKEventsProvider_init(o);
3904         return (long)res_ptr;
3905 }
3906 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
3907         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
3908         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
3909         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3910         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3911         for (size_t h = 0; h < ret_var.datalen; h++) {
3912                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
3913                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
3914                 long ret_conv_7_ref = (long)ret_conv_7_copy;
3915                 ret_arr_ptr[h] = ret_conv_7_ref;
3916         }
3917         FREE(ret_var.data);
3918         return ret_arr;
3919 }
3920
3921 typedef struct LDKAccess_JCalls {
3922         atomic_size_t refcnt;
3923         uint32_t get_utxo_meth;
3924 } LDKAccess_JCalls;
3925 static void LDKAccess_JCalls_free(void* this_arg) {
3926         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3927         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3928                 js_free(j_calls->get_utxo_meth);
3929                 FREE(j_calls);
3930         }
3931 }
3932 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3933         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3934         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3935         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
3936         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
3937         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
3938         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
3939         return ret_conv;
3940 }
3941 static void* LDKAccess_JCalls_clone(const void* this_arg) {
3942         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3943         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3944         return (void*) this_arg;
3945 }
3946 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
3947         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3948         atomic_init(&calls->refcnt, 1);
3949         //TODO: Assign calls->o from o
3950
3951         LDKAccess ret = {
3952                 .this_arg = (void*) calls,
3953                 .get_utxo = get_utxo_jcall,
3954                 .free = LDKAccess_JCalls_free,
3955         };
3956         return ret;
3957 }
3958 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
3959         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3960         *res_ptr = LDKAccess_init(o);
3961         return (long)res_ptr;
3962 }
3963 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3964         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
3965         unsigned char genesis_hash_arr[32];
3966         CHECK(*((uint32_t*)genesis_hash) == 32);
3967         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
3968         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3969         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3970         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3971         return (long)ret_conv;
3972 }
3973
3974 typedef struct LDKListen_JCalls {
3975         atomic_size_t refcnt;
3976         uint32_t block_connected_meth;
3977         uint32_t block_disconnected_meth;
3978 } LDKListen_JCalls;
3979 static void LDKListen_JCalls_free(void* this_arg) {
3980         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
3981         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3982                 js_free(j_calls->block_connected_meth);
3983                 js_free(j_calls->block_disconnected_meth);
3984                 FREE(j_calls);
3985         }
3986 }
3987 void block_connected_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
3988         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
3989         LDKu8slice block_var = block;
3990         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3991         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
3992         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
3993 }
3994 void block_disconnected_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
3995         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
3996         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
3997         memcpy((uint8_t*)(header_arr + 4), *header, 80);
3998         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
3999 }
4000 static void* LDKListen_JCalls_clone(const void* this_arg) {
4001         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4002         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4003         return (void*) this_arg;
4004 }
4005 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4006         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4007         atomic_init(&calls->refcnt, 1);
4008         //TODO: Assign calls->o from o
4009
4010         LDKListen ret = {
4011                 .this_arg = (void*) calls,
4012                 .block_connected = block_connected_jcall,
4013                 .block_disconnected = block_disconnected_jcall,
4014                 .free = LDKListen_JCalls_free,
4015         };
4016         return ret;
4017 }
4018 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4019         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4020         *res_ptr = LDKListen_init(o);
4021         return (long)res_ptr;
4022 }
4023 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4024         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4025         LDKu8slice block_ref;
4026         block_ref.datalen = *((uint32_t*)block);
4027         block_ref.data = (int8_t*)(block + 4);
4028         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4029 }
4030
4031 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4032         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4033         unsigned char header_arr[80];
4034         CHECK(*((uint32_t*)header) == 80);
4035         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4036         unsigned char (*header_ref)[80] = &header_arr;
4037         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4038 }
4039
4040 typedef struct LDKFilter_JCalls {
4041         atomic_size_t refcnt;
4042         uint32_t register_tx_meth;
4043         uint32_t register_output_meth;
4044 } LDKFilter_JCalls;
4045 static void LDKFilter_JCalls_free(void* this_arg) {
4046         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4047         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4048                 js_free(j_calls->register_tx_meth);
4049                 js_free(j_calls->register_output_meth);
4050                 FREE(j_calls);
4051         }
4052 }
4053 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4054         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4055         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4056         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4057         LDKu8slice script_pubkey_var = script_pubkey;
4058         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4059         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4060         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4061 }
4062 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
4063         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4064         LDKOutPoint outpoint_var = *outpoint;
4065         outpoint_var = OutPoint_clone(outpoint);
4066         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4067         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4068         long outpoint_ref = (long)outpoint_var.inner;
4069         if (outpoint_var.is_owned) {
4070                 outpoint_ref |= 1;
4071         }
4072         LDKu8slice script_pubkey_var = script_pubkey;
4073         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4074         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4075         js_invoke_function_2(j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
4076 }
4077 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4078         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4079         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4080         return (void*) this_arg;
4081 }
4082 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
4083         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4084         atomic_init(&calls->refcnt, 1);
4085         //TODO: Assign calls->o from o
4086
4087         LDKFilter ret = {
4088                 .this_arg = (void*) calls,
4089                 .register_tx = register_tx_jcall,
4090                 .register_output = register_output_jcall,
4091                 .free = LDKFilter_JCalls_free,
4092         };
4093         return ret;
4094 }
4095 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
4096         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4097         *res_ptr = LDKFilter_init(o);
4098         return (long)res_ptr;
4099 }
4100 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
4101         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4102         unsigned char txid_arr[32];
4103         CHECK(*((uint32_t*)txid) == 32);
4104         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
4105         unsigned char (*txid_ref)[32] = &txid_arr;
4106         LDKu8slice script_pubkey_ref;
4107         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4108         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4109         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4110 }
4111
4112 void  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
4113         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4114         LDKOutPoint outpoint_conv;
4115         outpoint_conv.inner = (void*)(outpoint & (~1));
4116         outpoint_conv.is_owned = false;
4117         LDKu8slice script_pubkey_ref;
4118         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4119         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4120         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
4121 }
4122
4123 typedef struct LDKPersist_JCalls {
4124         atomic_size_t refcnt;
4125         uint32_t persist_new_channel_meth;
4126         uint32_t update_persisted_channel_meth;
4127 } LDKPersist_JCalls;
4128 static void LDKPersist_JCalls_free(void* this_arg) {
4129         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4130         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4131                 js_free(j_calls->persist_new_channel_meth);
4132                 js_free(j_calls->update_persisted_channel_meth);
4133                 FREE(j_calls);
4134         }
4135 }
4136 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4137         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4138         LDKOutPoint id_var = id;
4139         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4140         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4141         long id_ref = (long)id_var.inner;
4142         if (id_var.is_owned) {
4143                 id_ref |= 1;
4144         }
4145         LDKChannelMonitor data_var = *data;
4146         data_var = ChannelMonitor_clone(data);
4147         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4148         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4149         long data_ref = (long)data_var.inner;
4150         if (data_var.is_owned) {
4151                 data_ref |= 1;
4152         }
4153         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
4154         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4155         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4156         return ret_conv;
4157 }
4158 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
4159         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4160         LDKOutPoint id_var = id;
4161         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4162         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4163         long id_ref = (long)id_var.inner;
4164         if (id_var.is_owned) {
4165                 id_ref |= 1;
4166         }
4167         LDKChannelMonitorUpdate update_var = *update;
4168         update_var = ChannelMonitorUpdate_clone(update);
4169         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4170         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4171         long update_ref = (long)update_var.inner;
4172         if (update_var.is_owned) {
4173                 update_ref |= 1;
4174         }
4175         LDKChannelMonitor data_var = *data;
4176         data_var = ChannelMonitor_clone(data);
4177         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4178         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4179         long data_ref = (long)data_var.inner;
4180         if (data_var.is_owned) {
4181                 data_ref |= 1;
4182         }
4183         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
4184         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4185         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4186         return ret_conv;
4187 }
4188 static void* LDKPersist_JCalls_clone(const void* this_arg) {
4189         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4190         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4191         return (void*) this_arg;
4192 }
4193 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
4194         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
4195         atomic_init(&calls->refcnt, 1);
4196         //TODO: Assign calls->o from o
4197
4198         LDKPersist ret = {
4199                 .this_arg = (void*) calls,
4200                 .persist_new_channel = persist_new_channel_jcall,
4201                 .update_persisted_channel = update_persisted_channel_jcall,
4202                 .free = LDKPersist_JCalls_free,
4203         };
4204         return ret;
4205 }
4206 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
4207         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
4208         *res_ptr = LDKPersist_init(o);
4209         return (long)res_ptr;
4210 }
4211 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
4212         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4213         LDKOutPoint id_conv;
4214         id_conv.inner = (void*)(id & (~1));
4215         id_conv.is_owned = (id & 1) || (id == 0);
4216         id_conv = OutPoint_clone(&id_conv);
4217         LDKChannelMonitor data_conv;
4218         data_conv.inner = (void*)(data & (~1));
4219         data_conv.is_owned = false;
4220         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4221         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
4222         return (long)ret_conv;
4223 }
4224
4225 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
4226         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4227         LDKOutPoint id_conv;
4228         id_conv.inner = (void*)(id & (~1));
4229         id_conv.is_owned = (id & 1) || (id == 0);
4230         id_conv = OutPoint_clone(&id_conv);
4231         LDKChannelMonitorUpdate update_conv;
4232         update_conv.inner = (void*)(update & (~1));
4233         update_conv.is_owned = false;
4234         LDKChannelMonitor data_conv;
4235         data_conv.inner = (void*)(data & (~1));
4236         data_conv.is_owned = false;
4237         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4238         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
4239         return (long)ret_conv;
4240 }
4241
4242 typedef struct LDKChannelMessageHandler_JCalls {
4243         atomic_size_t refcnt;
4244         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4245         uint32_t handle_open_channel_meth;
4246         uint32_t handle_accept_channel_meth;
4247         uint32_t handle_funding_created_meth;
4248         uint32_t handle_funding_signed_meth;
4249         uint32_t handle_funding_locked_meth;
4250         uint32_t handle_shutdown_meth;
4251         uint32_t handle_closing_signed_meth;
4252         uint32_t handle_update_add_htlc_meth;
4253         uint32_t handle_update_fulfill_htlc_meth;
4254         uint32_t handle_update_fail_htlc_meth;
4255         uint32_t handle_update_fail_malformed_htlc_meth;
4256         uint32_t handle_commitment_signed_meth;
4257         uint32_t handle_revoke_and_ack_meth;
4258         uint32_t handle_update_fee_meth;
4259         uint32_t handle_announcement_signatures_meth;
4260         uint32_t peer_disconnected_meth;
4261         uint32_t peer_connected_meth;
4262         uint32_t handle_channel_reestablish_meth;
4263         uint32_t handle_error_meth;
4264 } LDKChannelMessageHandler_JCalls;
4265 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
4266         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4267         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4268                 js_free(j_calls->handle_open_channel_meth);
4269                 js_free(j_calls->handle_accept_channel_meth);
4270                 js_free(j_calls->handle_funding_created_meth);
4271                 js_free(j_calls->handle_funding_signed_meth);
4272                 js_free(j_calls->handle_funding_locked_meth);
4273                 js_free(j_calls->handle_shutdown_meth);
4274                 js_free(j_calls->handle_closing_signed_meth);
4275                 js_free(j_calls->handle_update_add_htlc_meth);
4276                 js_free(j_calls->handle_update_fulfill_htlc_meth);
4277                 js_free(j_calls->handle_update_fail_htlc_meth);
4278                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
4279                 js_free(j_calls->handle_commitment_signed_meth);
4280                 js_free(j_calls->handle_revoke_and_ack_meth);
4281                 js_free(j_calls->handle_update_fee_meth);
4282                 js_free(j_calls->handle_announcement_signatures_meth);
4283                 js_free(j_calls->peer_disconnected_meth);
4284                 js_free(j_calls->peer_connected_meth);
4285                 js_free(j_calls->handle_channel_reestablish_meth);
4286                 js_free(j_calls->handle_error_meth);
4287                 FREE(j_calls);
4288         }
4289 }
4290 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
4291         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4292         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4293         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4294         LDKInitFeatures their_features_var = their_features;
4295         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4296         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4297         long their_features_ref = (long)their_features_var.inner;
4298         if (their_features_var.is_owned) {
4299                 their_features_ref |= 1;
4300         }
4301         LDKOpenChannel msg_var = *msg;
4302         msg_var = OpenChannel_clone(msg);
4303         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4304         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4305         long msg_ref = (long)msg_var.inner;
4306         if (msg_var.is_owned) {
4307                 msg_ref |= 1;
4308         }
4309         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4310 }
4311 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
4312         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4313         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4314         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4315         LDKInitFeatures their_features_var = their_features;
4316         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4317         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4318         long their_features_ref = (long)their_features_var.inner;
4319         if (their_features_var.is_owned) {
4320                 their_features_ref |= 1;
4321         }
4322         LDKAcceptChannel msg_var = *msg;
4323         msg_var = AcceptChannel_clone(msg);
4324         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4325         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4326         long msg_ref = (long)msg_var.inner;
4327         if (msg_var.is_owned) {
4328                 msg_ref |= 1;
4329         }
4330         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4331 }
4332 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
4333         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4334         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4335         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4336         LDKFundingCreated msg_var = *msg;
4337         msg_var = FundingCreated_clone(msg);
4338         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4339         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4340         long msg_ref = (long)msg_var.inner;
4341         if (msg_var.is_owned) {
4342                 msg_ref |= 1;
4343         }
4344         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
4345 }
4346 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
4347         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4348         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4349         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4350         LDKFundingSigned msg_var = *msg;
4351         msg_var = FundingSigned_clone(msg);
4352         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4353         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4354         long msg_ref = (long)msg_var.inner;
4355         if (msg_var.is_owned) {
4356                 msg_ref |= 1;
4357         }
4358         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
4359 }
4360 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
4361         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4362         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4363         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4364         LDKFundingLocked msg_var = *msg;
4365         msg_var = FundingLocked_clone(msg);
4366         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4367         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4368         long msg_ref = (long)msg_var.inner;
4369         if (msg_var.is_owned) {
4370                 msg_ref |= 1;
4371         }
4372         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
4373 }
4374 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
4375         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4376         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4377         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4378         LDKInitFeatures their_features_var = *their_features;
4379         their_features_var = InitFeatures_clone(their_features);
4380         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4381         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4382         long their_features_ref = (long)their_features_var.inner;
4383         if (their_features_var.is_owned) {
4384                 their_features_ref |= 1;
4385         }
4386         LDKShutdown msg_var = *msg;
4387         msg_var = Shutdown_clone(msg);
4388         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4389         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4390         long msg_ref = (long)msg_var.inner;
4391         if (msg_var.is_owned) {
4392                 msg_ref |= 1;
4393         }
4394         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
4395 }
4396 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
4397         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4398         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4399         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4400         LDKClosingSigned msg_var = *msg;
4401         msg_var = ClosingSigned_clone(msg);
4402         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4403         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4404         long msg_ref = (long)msg_var.inner;
4405         if (msg_var.is_owned) {
4406                 msg_ref |= 1;
4407         }
4408         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
4409 }
4410 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
4411         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4412         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4413         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4414         LDKUpdateAddHTLC msg_var = *msg;
4415         msg_var = UpdateAddHTLC_clone(msg);
4416         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4417         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4418         long msg_ref = (long)msg_var.inner;
4419         if (msg_var.is_owned) {
4420                 msg_ref |= 1;
4421         }
4422         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
4423 }
4424 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
4425         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4426         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4427         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4428         LDKUpdateFulfillHTLC msg_var = *msg;
4429         msg_var = UpdateFulfillHTLC_clone(msg);
4430         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4431         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4432         long msg_ref = (long)msg_var.inner;
4433         if (msg_var.is_owned) {
4434                 msg_ref |= 1;
4435         }
4436         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
4437 }
4438 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
4439         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4440         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4441         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4442         LDKUpdateFailHTLC msg_var = *msg;
4443         msg_var = UpdateFailHTLC_clone(msg);
4444         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4445         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4446         long msg_ref = (long)msg_var.inner;
4447         if (msg_var.is_owned) {
4448                 msg_ref |= 1;
4449         }
4450         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
4451 }
4452 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
4453         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4454         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4455         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4456         LDKUpdateFailMalformedHTLC msg_var = *msg;
4457         msg_var = UpdateFailMalformedHTLC_clone(msg);
4458         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4459         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4460         long msg_ref = (long)msg_var.inner;
4461         if (msg_var.is_owned) {
4462                 msg_ref |= 1;
4463         }
4464         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
4465 }
4466 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
4467         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4468         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4469         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4470         LDKCommitmentSigned msg_var = *msg;
4471         msg_var = CommitmentSigned_clone(msg);
4472         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4473         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4474         long msg_ref = (long)msg_var.inner;
4475         if (msg_var.is_owned) {
4476                 msg_ref |= 1;
4477         }
4478         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
4479 }
4480 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
4481         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4482         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4483         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4484         LDKRevokeAndACK msg_var = *msg;
4485         msg_var = RevokeAndACK_clone(msg);
4486         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4487         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4488         long msg_ref = (long)msg_var.inner;
4489         if (msg_var.is_owned) {
4490                 msg_ref |= 1;
4491         }
4492         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
4493 }
4494 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
4495         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4496         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4497         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4498         LDKUpdateFee msg_var = *msg;
4499         msg_var = UpdateFee_clone(msg);
4500         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4501         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4502         long msg_ref = (long)msg_var.inner;
4503         if (msg_var.is_owned) {
4504                 msg_ref |= 1;
4505         }
4506         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
4507 }
4508 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
4509         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4510         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4511         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4512         LDKAnnouncementSignatures msg_var = *msg;
4513         msg_var = AnnouncementSignatures_clone(msg);
4514         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4515         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4516         long msg_ref = (long)msg_var.inner;
4517         if (msg_var.is_owned) {
4518                 msg_ref |= 1;
4519         }
4520         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
4521 }
4522 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
4523         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4524         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4525         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4526         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
4527 }
4528 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
4529         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4530         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4531         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4532         LDKInit msg_var = *msg;
4533         msg_var = Init_clone(msg);
4534         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4535         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4536         long msg_ref = (long)msg_var.inner;
4537         if (msg_var.is_owned) {
4538                 msg_ref |= 1;
4539         }
4540         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
4541 }
4542 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
4543         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4544         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4545         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4546         LDKChannelReestablish msg_var = *msg;
4547         msg_var = ChannelReestablish_clone(msg);
4548         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         long msg_ref = (long)msg_var.inner;
4551         if (msg_var.is_owned) {
4552                 msg_ref |= 1;
4553         }
4554         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
4555 }
4556 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
4557         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4558         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4559         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4560         LDKErrorMessage msg_var = *msg;
4561         msg_var = ErrorMessage_clone(msg);
4562         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4563         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4564         long msg_ref = (long)msg_var.inner;
4565         if (msg_var.is_owned) {
4566                 msg_ref |= 1;
4567         }
4568         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
4569 }
4570 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
4571         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4572         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4573         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4574         return (void*) this_arg;
4575 }
4576 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4577         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
4578         atomic_init(&calls->refcnt, 1);
4579         //TODO: Assign calls->o from o
4580
4581         LDKChannelMessageHandler ret = {
4582                 .this_arg = (void*) calls,
4583                 .handle_open_channel = handle_open_channel_jcall,
4584                 .handle_accept_channel = handle_accept_channel_jcall,
4585                 .handle_funding_created = handle_funding_created_jcall,
4586                 .handle_funding_signed = handle_funding_signed_jcall,
4587                 .handle_funding_locked = handle_funding_locked_jcall,
4588                 .handle_shutdown = handle_shutdown_jcall,
4589                 .handle_closing_signed = handle_closing_signed_jcall,
4590                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
4591                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
4592                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
4593                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
4594                 .handle_commitment_signed = handle_commitment_signed_jcall,
4595                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
4596                 .handle_update_fee = handle_update_fee_jcall,
4597                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
4598                 .peer_disconnected = peer_disconnected_jcall,
4599                 .peer_connected = peer_connected_jcall,
4600                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
4601                 .handle_error = handle_error_jcall,
4602                 .free = LDKChannelMessageHandler_JCalls_free,
4603                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4604         };
4605         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4606         return ret;
4607 }
4608 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4609         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
4610         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
4611         return (long)res_ptr;
4612 }
4613 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) {
4614         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4615         LDKPublicKey their_node_id_ref;
4616         CHECK(*((uint32_t*)their_node_id) == 33);
4617         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4618         LDKInitFeatures their_features_conv;
4619         their_features_conv.inner = (void*)(their_features & (~1));
4620         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4621         their_features_conv = InitFeatures_clone(&their_features_conv);
4622         LDKOpenChannel msg_conv;
4623         msg_conv.inner = (void*)(msg & (~1));
4624         msg_conv.is_owned = false;
4625         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4626 }
4627
4628 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) {
4629         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4630         LDKPublicKey their_node_id_ref;
4631         CHECK(*((uint32_t*)their_node_id) == 33);
4632         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4633         LDKInitFeatures their_features_conv;
4634         their_features_conv.inner = (void*)(their_features & (~1));
4635         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4636         their_features_conv = InitFeatures_clone(&their_features_conv);
4637         LDKAcceptChannel msg_conv;
4638         msg_conv.inner = (void*)(msg & (~1));
4639         msg_conv.is_owned = false;
4640         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4641 }
4642
4643 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4644         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4645         LDKPublicKey their_node_id_ref;
4646         CHECK(*((uint32_t*)their_node_id) == 33);
4647         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4648         LDKFundingCreated msg_conv;
4649         msg_conv.inner = (void*)(msg & (~1));
4650         msg_conv.is_owned = false;
4651         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4652 }
4653
4654 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4655         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4656         LDKPublicKey their_node_id_ref;
4657         CHECK(*((uint32_t*)their_node_id) == 33);
4658         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4659         LDKFundingSigned msg_conv;
4660         msg_conv.inner = (void*)(msg & (~1));
4661         msg_conv.is_owned = false;
4662         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4663 }
4664
4665 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4666         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4667         LDKPublicKey their_node_id_ref;
4668         CHECK(*((uint32_t*)their_node_id) == 33);
4669         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4670         LDKFundingLocked msg_conv;
4671         msg_conv.inner = (void*)(msg & (~1));
4672         msg_conv.is_owned = false;
4673         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4674 }
4675
4676 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4677         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4678         LDKPublicKey their_node_id_ref;
4679         CHECK(*((uint32_t*)their_node_id) == 33);
4680         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4681         LDKInitFeatures their_features_conv;
4682         their_features_conv.inner = (void*)(their_features & (~1));
4683         their_features_conv.is_owned = false;
4684         LDKShutdown msg_conv;
4685         msg_conv.inner = (void*)(msg & (~1));
4686         msg_conv.is_owned = false;
4687         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
4688 }
4689
4690 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4691         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4692         LDKPublicKey their_node_id_ref;
4693         CHECK(*((uint32_t*)their_node_id) == 33);
4694         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4695         LDKClosingSigned msg_conv;
4696         msg_conv.inner = (void*)(msg & (~1));
4697         msg_conv.is_owned = false;
4698         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4699 }
4700
4701 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4702         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4703         LDKPublicKey their_node_id_ref;
4704         CHECK(*((uint32_t*)their_node_id) == 33);
4705         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4706         LDKUpdateAddHTLC msg_conv;
4707         msg_conv.inner = (void*)(msg & (~1));
4708         msg_conv.is_owned = false;
4709         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4710 }
4711
4712 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4713         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4714         LDKPublicKey their_node_id_ref;
4715         CHECK(*((uint32_t*)their_node_id) == 33);
4716         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4717         LDKUpdateFulfillHTLC msg_conv;
4718         msg_conv.inner = (void*)(msg & (~1));
4719         msg_conv.is_owned = false;
4720         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4721 }
4722
4723 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4724         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4725         LDKPublicKey their_node_id_ref;
4726         CHECK(*((uint32_t*)their_node_id) == 33);
4727         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4728         LDKUpdateFailHTLC msg_conv;
4729         msg_conv.inner = (void*)(msg & (~1));
4730         msg_conv.is_owned = false;
4731         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4732 }
4733
4734 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4735         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4736         LDKPublicKey their_node_id_ref;
4737         CHECK(*((uint32_t*)their_node_id) == 33);
4738         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4739         LDKUpdateFailMalformedHTLC msg_conv;
4740         msg_conv.inner = (void*)(msg & (~1));
4741         msg_conv.is_owned = false;
4742         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4743 }
4744
4745 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4746         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4747         LDKPublicKey their_node_id_ref;
4748         CHECK(*((uint32_t*)their_node_id) == 33);
4749         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4750         LDKCommitmentSigned msg_conv;
4751         msg_conv.inner = (void*)(msg & (~1));
4752         msg_conv.is_owned = false;
4753         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4754 }
4755
4756 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4758         LDKPublicKey their_node_id_ref;
4759         CHECK(*((uint32_t*)their_node_id) == 33);
4760         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4761         LDKRevokeAndACK msg_conv;
4762         msg_conv.inner = (void*)(msg & (~1));
4763         msg_conv.is_owned = false;
4764         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4765 }
4766
4767 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4768         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4769         LDKPublicKey their_node_id_ref;
4770         CHECK(*((uint32_t*)their_node_id) == 33);
4771         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4772         LDKUpdateFee msg_conv;
4773         msg_conv.inner = (void*)(msg & (~1));
4774         msg_conv.is_owned = false;
4775         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4776 }
4777
4778 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4779         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4780         LDKPublicKey their_node_id_ref;
4781         CHECK(*((uint32_t*)their_node_id) == 33);
4782         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4783         LDKAnnouncementSignatures msg_conv;
4784         msg_conv.inner = (void*)(msg & (~1));
4785         msg_conv.is_owned = false;
4786         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4787 }
4788
4789 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
4790         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4791         LDKPublicKey their_node_id_ref;
4792         CHECK(*((uint32_t*)their_node_id) == 33);
4793         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4794         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
4795 }
4796
4797 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4798         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4799         LDKPublicKey their_node_id_ref;
4800         CHECK(*((uint32_t*)their_node_id) == 33);
4801         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4802         LDKInit msg_conv;
4803         msg_conv.inner = (void*)(msg & (~1));
4804         msg_conv.is_owned = false;
4805         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4806 }
4807
4808 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4809         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4810         LDKPublicKey their_node_id_ref;
4811         CHECK(*((uint32_t*)their_node_id) == 33);
4812         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4813         LDKChannelReestablish msg_conv;
4814         msg_conv.inner = (void*)(msg & (~1));
4815         msg_conv.is_owned = false;
4816         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4817 }
4818
4819 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4820         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4821         LDKPublicKey their_node_id_ref;
4822         CHECK(*((uint32_t*)their_node_id) == 33);
4823         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4824         LDKErrorMessage msg_conv;
4825         msg_conv.inner = (void*)(msg & (~1));
4826         msg_conv.is_owned = false;
4827         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4828 }
4829
4830 typedef struct LDKRoutingMessageHandler_JCalls {
4831         atomic_size_t refcnt;
4832         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4833         uint32_t handle_node_announcement_meth;
4834         uint32_t handle_channel_announcement_meth;
4835         uint32_t handle_channel_update_meth;
4836         uint32_t handle_htlc_fail_channel_update_meth;
4837         uint32_t get_next_channel_announcements_meth;
4838         uint32_t get_next_node_announcements_meth;
4839         uint32_t sync_routing_table_meth;
4840         uint32_t handle_reply_channel_range_meth;
4841         uint32_t handle_reply_short_channel_ids_end_meth;
4842         uint32_t handle_query_channel_range_meth;
4843         uint32_t handle_query_short_channel_ids_meth;
4844 } LDKRoutingMessageHandler_JCalls;
4845 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
4846         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4847         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4848                 js_free(j_calls->handle_node_announcement_meth);
4849                 js_free(j_calls->handle_channel_announcement_meth);
4850                 js_free(j_calls->handle_channel_update_meth);
4851                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
4852                 js_free(j_calls->get_next_channel_announcements_meth);
4853                 js_free(j_calls->get_next_node_announcements_meth);
4854                 js_free(j_calls->sync_routing_table_meth);
4855                 js_free(j_calls->handle_reply_channel_range_meth);
4856                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
4857                 js_free(j_calls->handle_query_channel_range_meth);
4858                 js_free(j_calls->handle_query_short_channel_ids_meth);
4859                 FREE(j_calls);
4860         }
4861 }
4862 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
4863         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4864         LDKNodeAnnouncement msg_var = *msg;
4865         msg_var = NodeAnnouncement_clone(msg);
4866         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4867         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4868         long msg_ref = (long)msg_var.inner;
4869         if (msg_var.is_owned) {
4870                 msg_ref |= 1;
4871         }
4872         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
4873         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4874         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4875         return ret_conv;
4876 }
4877 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
4878         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4879         LDKChannelAnnouncement msg_var = *msg;
4880         msg_var = ChannelAnnouncement_clone(msg);
4881         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4882         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4883         long msg_ref = (long)msg_var.inner;
4884         if (msg_var.is_owned) {
4885                 msg_ref |= 1;
4886         }
4887         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
4888         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4889         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4890         return ret_conv;
4891 }
4892 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
4893         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4894         LDKChannelUpdate msg_var = *msg;
4895         msg_var = ChannelUpdate_clone(msg);
4896         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4897         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4898         long msg_ref = (long)msg_var.inner;
4899         if (msg_var.is_owned) {
4900                 msg_ref |= 1;
4901         }
4902         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
4903         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4904         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4905         return ret_conv;
4906 }
4907 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
4908         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4909         long ret_update = (long)update;
4910         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
4911 }
4912 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
4913         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4914         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
4915         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
4916         ret_constr.datalen = *((uint32_t*)ret);
4917         if (ret_constr.datalen > 0)
4918                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4919         else
4920                 ret_constr.data = NULL;
4921         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4922         for (size_t l = 0; l < ret_constr.datalen; l++) {
4923                 uint32_t ret_conv_63 = ret_vals[l];
4924                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
4925                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ret_conv_63);
4926                 ret_constr.data[l] = ret_conv_63_conv;
4927         }
4928         return ret_constr;
4929 }
4930 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
4931         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4932         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4933         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
4934         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
4935         LDKCVec_NodeAnnouncementZ ret_constr;
4936         ret_constr.datalen = *((uint32_t*)ret);
4937         if (ret_constr.datalen > 0)
4938                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4939         else
4940                 ret_constr.data = NULL;
4941         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4942         for (size_t s = 0; s < ret_constr.datalen; s++) {
4943                 uint32_t ret_conv_18 = ret_vals[s];
4944                 LDKNodeAnnouncement ret_conv_18_conv;
4945                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
4946                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
4947                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
4948                 ret_constr.data[s] = ret_conv_18_conv;
4949         }
4950         return ret_constr;
4951 }
4952 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
4953         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4954         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4955         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4956         LDKInit init_var = *init;
4957         init_var = Init_clone(init);
4958         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4959         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4960         long init_ref = (long)init_var.inner;
4961         if (init_var.is_owned) {
4962                 init_ref |= 1;
4963         }
4964         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
4965 }
4966 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
4967         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4968         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4969         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4970         LDKReplyChannelRange msg_var = msg;
4971         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4972         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4973         long msg_ref = (long)msg_var.inner;
4974         if (msg_var.is_owned) {
4975                 msg_ref |= 1;
4976         }
4977         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
4978         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
4979         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
4980         return ret_conv;
4981 }
4982 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
4983         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4984         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4985         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4986         LDKReplyShortChannelIdsEnd msg_var = msg;
4987         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4988         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4989         long msg_ref = (long)msg_var.inner;
4990         if (msg_var.is_owned) {
4991                 msg_ref |= 1;
4992         }
4993         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
4994         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
4995         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
4996         return ret_conv;
4997 }
4998 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
4999         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5000         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5001         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5002         LDKQueryChannelRange msg_var = msg;
5003         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5004         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5005         long msg_ref = (long)msg_var.inner;
5006         if (msg_var.is_owned) {
5007                 msg_ref |= 1;
5008         }
5009         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
5010         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5011         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5012         return ret_conv;
5013 }
5014 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
5015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5016         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5017         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5018         LDKQueryShortChannelIds msg_var = msg;
5019         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5020         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5021         long msg_ref = (long)msg_var.inner;
5022         if (msg_var.is_owned) {
5023                 msg_ref |= 1;
5024         }
5025         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
5026         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5027         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5028         return ret_conv;
5029 }
5030 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
5031         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5032         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5033         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5034         return (void*) this_arg;
5035 }
5036 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5037         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
5038         atomic_init(&calls->refcnt, 1);
5039         //TODO: Assign calls->o from o
5040
5041         LDKRoutingMessageHandler ret = {
5042                 .this_arg = (void*) calls,
5043                 .handle_node_announcement = handle_node_announcement_jcall,
5044                 .handle_channel_announcement = handle_channel_announcement_jcall,
5045                 .handle_channel_update = handle_channel_update_jcall,
5046                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
5047                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
5048                 .get_next_node_announcements = get_next_node_announcements_jcall,
5049                 .sync_routing_table = sync_routing_table_jcall,
5050                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
5051                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
5052                 .handle_query_channel_range = handle_query_channel_range_jcall,
5053                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
5054                 .free = LDKRoutingMessageHandler_JCalls_free,
5055                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5056         };
5057         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5058         return ret;
5059 }
5060 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5061         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
5062         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
5063         return (long)res_ptr;
5064 }
5065 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
5066         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5067         LDKNodeAnnouncement msg_conv;
5068         msg_conv.inner = (void*)(msg & (~1));
5069         msg_conv.is_owned = false;
5070         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5071         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
5072         return (long)ret_conv;
5073 }
5074
5075 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
5076         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5077         LDKChannelAnnouncement msg_conv;
5078         msg_conv.inner = (void*)(msg & (~1));
5079         msg_conv.is_owned = false;
5080         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5081         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5082         return (long)ret_conv;
5083 }
5084
5085 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
5086         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5087         LDKChannelUpdate msg_conv;
5088         msg_conv.inner = (void*)(msg & (~1));
5089         msg_conv.is_owned = false;
5090         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5091         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
5092         return (long)ret_conv;
5093 }
5094
5095 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
5096         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5097         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
5098         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
5099 }
5100
5101 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
5102         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5103         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
5104         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5105         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5106         for (size_t l = 0; l < ret_var.datalen; l++) {
5107                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5108                 *ret_conv_63_ref = ret_var.data[l];
5109                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
5110         }
5111         FREE(ret_var.data);
5112         return ret_arr;
5113 }
5114
5115 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
5116         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5117         LDKPublicKey starting_point_ref;
5118         CHECK(*((uint32_t*)starting_point) == 33);
5119         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
5120         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
5121         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5122         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5123         for (size_t s = 0; s < ret_var.datalen; s++) {
5124                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
5125                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
5128                 if (ret_conv_18_var.is_owned) {
5129                         ret_conv_18_ref |= 1;
5130                 }
5131                 ret_arr_ptr[s] = ret_conv_18_ref;
5132         }
5133         FREE(ret_var.data);
5134         return ret_arr;
5135 }
5136
5137 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
5138         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5139         LDKPublicKey their_node_id_ref;
5140         CHECK(*((uint32_t*)their_node_id) == 33);
5141         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5142         LDKInit init_conv;
5143         init_conv.inner = (void*)(init & (~1));
5144         init_conv.is_owned = false;
5145         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
5146 }
5147
5148 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5149         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5150         LDKPublicKey their_node_id_ref;
5151         CHECK(*((uint32_t*)their_node_id) == 33);
5152         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5153         LDKReplyChannelRange msg_conv;
5154         msg_conv.inner = (void*)(msg & (~1));
5155         msg_conv.is_owned = (msg & 1) || (msg == 0);
5156         msg_conv = ReplyChannelRange_clone(&msg_conv);
5157         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5158         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5159         return (long)ret_conv;
5160 }
5161
5162 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) {
5163         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5164         LDKPublicKey their_node_id_ref;
5165         CHECK(*((uint32_t*)their_node_id) == 33);
5166         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5167         LDKReplyShortChannelIdsEnd msg_conv;
5168         msg_conv.inner = (void*)(msg & (~1));
5169         msg_conv.is_owned = (msg & 1) || (msg == 0);
5170         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
5171         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5172         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5173         return (long)ret_conv;
5174 }
5175
5176 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5177         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5178         LDKPublicKey their_node_id_ref;
5179         CHECK(*((uint32_t*)their_node_id) == 33);
5180         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5181         LDKQueryChannelRange msg_conv;
5182         msg_conv.inner = (void*)(msg & (~1));
5183         msg_conv.is_owned = (msg & 1) || (msg == 0);
5184         msg_conv = QueryChannelRange_clone(&msg_conv);
5185         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5186         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5187         return (long)ret_conv;
5188 }
5189
5190 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5191         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5192         LDKPublicKey their_node_id_ref;
5193         CHECK(*((uint32_t*)their_node_id) == 33);
5194         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5195         LDKQueryShortChannelIds msg_conv;
5196         msg_conv.inner = (void*)(msg & (~1));
5197         msg_conv.is_owned = (msg & 1) || (msg == 0);
5198         msg_conv = QueryShortChannelIds_clone(&msg_conv);
5199         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5200         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5201         return (long)ret_conv;
5202 }
5203
5204 typedef struct LDKSocketDescriptor_JCalls {
5205         atomic_size_t refcnt;
5206         uint32_t send_data_meth;
5207         uint32_t disconnect_socket_meth;
5208         uint32_t eq_meth;
5209         uint32_t hash_meth;
5210 } LDKSocketDescriptor_JCalls;
5211 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
5212         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5213         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5214                 js_free(j_calls->send_data_meth);
5215                 js_free(j_calls->disconnect_socket_meth);
5216                 js_free(j_calls->eq_meth);
5217                 js_free(j_calls->hash_meth);
5218                 FREE(j_calls);
5219         }
5220 }
5221 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
5222         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5223         LDKu8slice data_var = data;
5224         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5225         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
5226         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
5227 }
5228 void disconnect_socket_jcall(void* this_arg) {
5229         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5230         js_invoke_function_0(j_calls->disconnect_socket_meth);
5231 }
5232 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
5233         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5234         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5235         *other_arg_clone = SocketDescriptor_clone(other_arg);
5236         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
5237 }
5238 uint64_t hash_jcall(const void* this_arg) {
5239         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5240         return js_invoke_function_0(j_calls->hash_meth);
5241 }
5242 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
5243         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5244         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5245         return (void*) this_arg;
5246 }
5247 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
5248         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
5249         atomic_init(&calls->refcnt, 1);
5250         //TODO: Assign calls->o from o
5251
5252         LDKSocketDescriptor ret = {
5253                 .this_arg = (void*) calls,
5254                 .send_data = send_data_jcall,
5255                 .disconnect_socket = disconnect_socket_jcall,
5256                 .eq = eq_jcall,
5257                 .hash = hash_jcall,
5258                 .clone = LDKSocketDescriptor_JCalls_clone,
5259                 .free = LDKSocketDescriptor_JCalls_free,
5260         };
5261         return ret;
5262 }
5263 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
5264         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5265         *res_ptr = LDKSocketDescriptor_init(o);
5266         return (long)res_ptr;
5267 }
5268 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
5269         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5270         LDKu8slice data_ref;
5271         data_ref.datalen = *((uint32_t*)data);
5272         data_ref.data = (int8_t*)(data + 4);
5273         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
5274         return ret_val;
5275 }
5276
5277 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
5278         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5279         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
5280 }
5281
5282 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
5283         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5284         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
5285         return ret_val;
5286 }
5287
5288 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
5289         LDKTransaction _res_ref;
5290         _res_ref.datalen = *((uint32_t*)_res);
5291         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
5292         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5293         _res_ref.data_is_owned = true;
5294         Transaction_free(_res_ref);
5295 }
5296
5297 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
5298         if ((_res & 1) != 0) return;
5299         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
5300         FREE((void*)_res);
5301         TxOut_free(_res_conv);
5302 }
5303
5304 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
5305         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
5306         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5307         *ret_ref = TxOut_clone(orig_conv);
5308         return (long)ret_ref;
5309 }
5310
5311 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
5312         LDKSecretKey o_ref;
5313         CHECK(*((uint32_t*)o) == 32);
5314         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5315         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5316         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
5317         return (long)ret_conv;
5318 }
5319
5320 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
5321         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5322         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5323         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
5324         return (long)ret_conv;
5325 }
5326
5327 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
5328         if ((_res & 1) != 0) return;
5329         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
5330         FREE((void*)_res);
5331         CResult_SecretKeyErrorZ_free(_res_conv);
5332 }
5333
5334 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
5335         LDKPublicKey o_ref;
5336         CHECK(*((uint32_t*)o) == 33);
5337         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5338         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5339         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
5340         return (long)ret_conv;
5341 }
5342
5343 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
5344         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5345         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5346         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
5347         return (long)ret_conv;
5348 }
5349
5350 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
5351         if ((_res & 1) != 0) return;
5352         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
5353         FREE((void*)_res);
5354         CResult_PublicKeyErrorZ_free(_res_conv);
5355 }
5356
5357 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
5358         LDKTxCreationKeys o_conv;
5359         o_conv.inner = (void*)(o & (~1));
5360         o_conv.is_owned = (o & 1) || (o == 0);
5361         o_conv = TxCreationKeys_clone(&o_conv);
5362         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5363         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
5364         return (long)ret_conv;
5365 }
5366
5367 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
5368         LDKDecodeError e_conv;
5369         e_conv.inner = (void*)(e & (~1));
5370         e_conv.is_owned = (e & 1) || (e == 0);
5371         e_conv = DecodeError_clone(&e_conv);
5372         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5373         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
5374         return (long)ret_conv;
5375 }
5376
5377 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
5378         if ((_res & 1) != 0) return;
5379         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5380         FREE((void*)_res);
5381         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
5382 }
5383
5384 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
5385         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
5386         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5387         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
5388         return (long)ret_conv;
5389 }
5390
5391 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
5392         LDKChannelPublicKeys o_conv;
5393         o_conv.inner = (void*)(o & (~1));
5394         o_conv.is_owned = (o & 1) || (o == 0);
5395         o_conv = ChannelPublicKeys_clone(&o_conv);
5396         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5397         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
5398         return (long)ret_conv;
5399 }
5400
5401 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
5402         LDKDecodeError e_conv;
5403         e_conv.inner = (void*)(e & (~1));
5404         e_conv.is_owned = (e & 1) || (e == 0);
5405         e_conv = DecodeError_clone(&e_conv);
5406         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5407         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
5408         return (long)ret_conv;
5409 }
5410
5411 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
5412         if ((_res & 1) != 0) return;
5413         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5414         FREE((void*)_res);
5415         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
5416 }
5417
5418 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
5419         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
5420         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5421         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
5422         return (long)ret_conv;
5423 }
5424
5425 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
5426         LDKTxCreationKeys o_conv;
5427         o_conv.inner = (void*)(o & (~1));
5428         o_conv.is_owned = (o & 1) || (o == 0);
5429         o_conv = TxCreationKeys_clone(&o_conv);
5430         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5431         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
5432         return (long)ret_conv;
5433 }
5434
5435 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
5436         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5437         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5438         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
5439         return (long)ret_conv;
5440 }
5441
5442 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
5443         if ((_res & 1) != 0) return;
5444         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
5445         FREE((void*)_res);
5446         CResult_TxCreationKeysErrorZ_free(_res_conv);
5447 }
5448
5449 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
5450         LDKHTLCOutputInCommitment o_conv;
5451         o_conv.inner = (void*)(o & (~1));
5452         o_conv.is_owned = (o & 1) || (o == 0);
5453         o_conv = HTLCOutputInCommitment_clone(&o_conv);
5454         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5455         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
5456         return (long)ret_conv;
5457 }
5458
5459 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
5460         LDKDecodeError e_conv;
5461         e_conv.inner = (void*)(e & (~1));
5462         e_conv.is_owned = (e & 1) || (e == 0);
5463         e_conv = DecodeError_clone(&e_conv);
5464         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5465         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
5466         return (long)ret_conv;
5467 }
5468
5469 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
5470         if ((_res & 1) != 0) return;
5471         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
5472         FREE((void*)_res);
5473         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
5474 }
5475
5476 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
5477         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
5478         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5479         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
5480         return (long)ret_conv;
5481 }
5482
5483 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5484         LDKCounterpartyChannelTransactionParameters o_conv;
5485         o_conv.inner = (void*)(o & (~1));
5486         o_conv.is_owned = (o & 1) || (o == 0);
5487         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
5488         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5489         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5490         return (long)ret_conv;
5491 }
5492
5493 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5494         LDKDecodeError e_conv;
5495         e_conv.inner = (void*)(e & (~1));
5496         e_conv.is_owned = (e & 1) || (e == 0);
5497         e_conv = DecodeError_clone(&e_conv);
5498         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5499         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
5500         return (long)ret_conv;
5501 }
5502
5503 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5504         if ((_res & 1) != 0) return;
5505         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5506         FREE((void*)_res);
5507         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5508 }
5509
5510 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5511         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5512         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5513         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5514         return (long)ret_conv;
5515 }
5516
5517 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5518         LDKChannelTransactionParameters o_conv;
5519         o_conv.inner = (void*)(o & (~1));
5520         o_conv.is_owned = (o & 1) || (o == 0);
5521         o_conv = ChannelTransactionParameters_clone(&o_conv);
5522         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5523         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5524         return (long)ret_conv;
5525 }
5526
5527 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5528         LDKDecodeError e_conv;
5529         e_conv.inner = (void*)(e & (~1));
5530         e_conv.is_owned = (e & 1) || (e == 0);
5531         e_conv = DecodeError_clone(&e_conv);
5532         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5533         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
5534         return (long)ret_conv;
5535 }
5536
5537 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5538         if ((_res & 1) != 0) return;
5539         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5540         FREE((void*)_res);
5541         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5542 }
5543
5544 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5545         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5546         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5547         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5548         return (long)ret_conv;
5549 }
5550
5551 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
5552         LDKCVec_SignatureZ _res_constr;
5553         _res_constr.datalen = *((uint32_t*)_res);
5554         if (_res_constr.datalen > 0)
5555                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5556         else
5557                 _res_constr.data = NULL;
5558         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5559         for (size_t m = 0; m < _res_constr.datalen; m++) {
5560                 int8_tArray _res_conv_12 = _res_vals[m];
5561                 LDKSignature _res_conv_12_ref;
5562                 CHECK(*((uint32_t*)_res_conv_12) == 64);
5563                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
5564                 _res_constr.data[m] = _res_conv_12_ref;
5565         }
5566         CVec_SignatureZ_free(_res_constr);
5567 }
5568
5569 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5570         LDKHolderCommitmentTransaction o_conv;
5571         o_conv.inner = (void*)(o & (~1));
5572         o_conv.is_owned = (o & 1) || (o == 0);
5573         o_conv = HolderCommitmentTransaction_clone(&o_conv);
5574         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5575         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
5576         return (long)ret_conv;
5577 }
5578
5579 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5580         LDKDecodeError e_conv;
5581         e_conv.inner = (void*)(e & (~1));
5582         e_conv.is_owned = (e & 1) || (e == 0);
5583         e_conv = DecodeError_clone(&e_conv);
5584         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5585         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
5586         return (long)ret_conv;
5587 }
5588
5589 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5590         if ((_res & 1) != 0) return;
5591         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5592         FREE((void*)_res);
5593         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
5594 }
5595
5596 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5597         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5598         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5599         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5600         return (long)ret_conv;
5601 }
5602
5603 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5604         LDKBuiltCommitmentTransaction o_conv;
5605         o_conv.inner = (void*)(o & (~1));
5606         o_conv.is_owned = (o & 1) || (o == 0);
5607         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
5608         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5609         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
5610         return (long)ret_conv;
5611 }
5612
5613 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5614         LDKDecodeError e_conv;
5615         e_conv.inner = (void*)(e & (~1));
5616         e_conv.is_owned = (e & 1) || (e == 0);
5617         e_conv = DecodeError_clone(&e_conv);
5618         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5619         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
5620         return (long)ret_conv;
5621 }
5622
5623 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5624         if ((_res & 1) != 0) return;
5625         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5626         FREE((void*)_res);
5627         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
5628 }
5629
5630 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5631         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5632         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5633         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5634         return (long)ret_conv;
5635 }
5636
5637 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5638         LDKCommitmentTransaction o_conv;
5639         o_conv.inner = (void*)(o & (~1));
5640         o_conv.is_owned = (o & 1) || (o == 0);
5641         o_conv = CommitmentTransaction_clone(&o_conv);
5642         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5643         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
5644         return (long)ret_conv;
5645 }
5646
5647 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5648         LDKDecodeError e_conv;
5649         e_conv.inner = (void*)(e & (~1));
5650         e_conv.is_owned = (e & 1) || (e == 0);
5651         e_conv = DecodeError_clone(&e_conv);
5652         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5653         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
5654         return (long)ret_conv;
5655 }
5656
5657 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5658         if ((_res & 1) != 0) return;
5659         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5660         FREE((void*)_res);
5661         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
5662 }
5663
5664 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5665         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
5666         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5667         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
5668         return (long)ret_conv;
5669 }
5670
5671 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
5672         LDKTrustedCommitmentTransaction o_conv;
5673         o_conv.inner = (void*)(o & (~1));
5674         o_conv.is_owned = (o & 1) || (o == 0);
5675         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
5676         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5677         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5678         return (long)ret_conv;
5679 }
5680
5681 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
5682         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5683         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5684         return (long)ret_conv;
5685 }
5686
5687 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
5688         if ((_res & 1) != 0) return;
5689         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
5690         FREE((void*)_res);
5691         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5692 }
5693
5694 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
5695         LDKCVec_SignatureZ o_constr;
5696         o_constr.datalen = *((uint32_t*)o);
5697         if (o_constr.datalen > 0)
5698                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5699         else
5700                 o_constr.data = NULL;
5701         int8_tArray* o_vals = (int8_tArray*)(o + 4);
5702         for (size_t m = 0; m < o_constr.datalen; m++) {
5703                 int8_tArray o_conv_12 = o_vals[m];
5704                 LDKSignature o_conv_12_ref;
5705                 CHECK(*((uint32_t*)o_conv_12) == 64);
5706                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
5707                 o_constr.data[m] = o_conv_12_ref;
5708         }
5709         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5710         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
5711         return (long)ret_conv;
5712 }
5713
5714 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
5715         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5716         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
5717         return (long)ret_conv;
5718 }
5719
5720 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5721         if ((_res & 1) != 0) return;
5722         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
5723         FREE((void*)_res);
5724         CResult_CVec_SignatureZNoneZ_free(_res_conv);
5725 }
5726
5727 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
5728         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
5729         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5730         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
5731         return (long)ret_conv;
5732 }
5733
5734 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
5735         LDKCVec_MessageSendEventZ _res_constr;
5736         _res_constr.datalen = *((uint32_t*)_res);
5737         if (_res_constr.datalen > 0)
5738                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5739         else
5740                 _res_constr.data = NULL;
5741         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5742         for (size_t s = 0; s < _res_constr.datalen; s++) {
5743                 uint32_t _res_conv_18 = _res_vals[s];
5744                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
5745                 FREE((void*)_res_conv_18);
5746                 _res_constr.data[s] = _res_conv_18_conv;
5747         }
5748         CVec_MessageSendEventZ_free(_res_constr);
5749 }
5750
5751 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5752         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5753         *ret_conv = CResult_boolLightningErrorZ_ok(o);
5754         return (long)ret_conv;
5755 }
5756
5757 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5758         LDKLightningError e_conv;
5759         e_conv.inner = (void*)(e & (~1));
5760         e_conv.is_owned = (e & 1) || (e == 0);
5761         e_conv = LightningError_clone(&e_conv);
5762         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5763         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5764         return (long)ret_conv;
5765 }
5766
5767 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5768         if ((_res & 1) != 0) return;
5769         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
5770         FREE((void*)_res);
5771         CResult_boolLightningErrorZ_free(_res_conv);
5772 }
5773
5774 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
5775         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
5776         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5777         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
5778         return (long)ret_conv;
5779 }
5780
5781 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
5782         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
5783         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5784         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
5785         return (long)ret_ref;
5786 }
5787
5788 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5789         LDKChannelAnnouncement a_conv;
5790         a_conv.inner = (void*)(a & (~1));
5791         a_conv.is_owned = (a & 1) || (a == 0);
5792         a_conv = ChannelAnnouncement_clone(&a_conv);
5793         LDKChannelUpdate b_conv;
5794         b_conv.inner = (void*)(b & (~1));
5795         b_conv.is_owned = (b & 1) || (b == 0);
5796         b_conv = ChannelUpdate_clone(&b_conv);
5797         LDKChannelUpdate c_conv;
5798         c_conv.inner = (void*)(c & (~1));
5799         c_conv.is_owned = (c & 1) || (c == 0);
5800         c_conv = ChannelUpdate_clone(&c_conv);
5801         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5802         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5803         return (long)ret_ref;
5804 }
5805
5806 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5807         if ((_res & 1) != 0) return;
5808         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
5809         FREE((void*)_res);
5810         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5811 }
5812
5813 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5814         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5815         _res_constr.datalen = *((uint32_t*)_res);
5816         if (_res_constr.datalen > 0)
5817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5818         else
5819                 _res_constr.data = NULL;
5820         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5821         for (size_t l = 0; l < _res_constr.datalen; l++) {
5822                 uint32_t _res_conv_63 = _res_vals[l];
5823                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
5824                 FREE((void*)_res_conv_63);
5825                 _res_constr.data[l] = _res_conv_63_conv;
5826         }
5827         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5828 }
5829
5830 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5831         LDKCVec_NodeAnnouncementZ _res_constr;
5832         _res_constr.datalen = *((uint32_t*)_res);
5833         if (_res_constr.datalen > 0)
5834                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5835         else
5836                 _res_constr.data = NULL;
5837         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5838         for (size_t s = 0; s < _res_constr.datalen; s++) {
5839                 uint32_t _res_conv_18 = _res_vals[s];
5840                 LDKNodeAnnouncement _res_conv_18_conv;
5841                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
5842                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
5843                 _res_constr.data[s] = _res_conv_18_conv;
5844         }
5845         CVec_NodeAnnouncementZ_free(_res_constr);
5846 }
5847
5848 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
5849         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5850         *ret_conv = CResult_NoneLightningErrorZ_ok();
5851         return (long)ret_conv;
5852 }
5853
5854 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
5855         LDKLightningError e_conv;
5856         e_conv.inner = (void*)(e & (~1));
5857         e_conv.is_owned = (e & 1) || (e == 0);
5858         e_conv = LightningError_clone(&e_conv);
5859         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5860         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
5861         return (long)ret_conv;
5862 }
5863
5864 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
5865         if ((_res & 1) != 0) return;
5866         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
5867         FREE((void*)_res);
5868         CResult_NoneLightningErrorZ_free(_res_conv);
5869 }
5870
5871 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
5872         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
5873         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5874         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
5875         return (long)ret_conv;
5876 }
5877
5878 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
5879         LDKCVec_PublicKeyZ _res_constr;
5880         _res_constr.datalen = *((uint32_t*)_res);
5881         if (_res_constr.datalen > 0)
5882                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
5883         else
5884                 _res_constr.data = NULL;
5885         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5886         for (size_t m = 0; m < _res_constr.datalen; m++) {
5887                 int8_tArray _res_conv_12 = _res_vals[m];
5888                 LDKPublicKey _res_conv_12_ref;
5889                 CHECK(*((uint32_t*)_res_conv_12) == 33);
5890                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
5891                 _res_constr.data[m] = _res_conv_12_ref;
5892         }
5893         CVec_PublicKeyZ_free(_res_constr);
5894 }
5895
5896 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
5897         LDKCVec_u8Z _res_ref;
5898         _res_ref.datalen = *((uint32_t*)_res);
5899         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
5900         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5901         CVec_u8Z_free(_res_ref);
5902 }
5903
5904 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
5905         LDKCVec_u8Z o_ref;
5906         o_ref.datalen = *((uint32_t*)o);
5907         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
5908         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
5909         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5910         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
5911         return (long)ret_conv;
5912 }
5913
5914 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
5915         LDKPeerHandleError e_conv;
5916         e_conv.inner = (void*)(e & (~1));
5917         e_conv.is_owned = (e & 1) || (e == 0);
5918         e_conv = PeerHandleError_clone(&e_conv);
5919         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5920         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
5921         return (long)ret_conv;
5922 }
5923
5924 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
5925         if ((_res & 1) != 0) return;
5926         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5927         FREE((void*)_res);
5928         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
5929 }
5930
5931 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
5932         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
5933         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5934         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
5935         return (long)ret_conv;
5936 }
5937
5938 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
5939         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5940         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
5941         return (long)ret_conv;
5942 }
5943
5944 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
5945         LDKPeerHandleError e_conv;
5946         e_conv.inner = (void*)(e & (~1));
5947         e_conv.is_owned = (e & 1) || (e == 0);
5948         e_conv = PeerHandleError_clone(&e_conv);
5949         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5950         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
5951         return (long)ret_conv;
5952 }
5953
5954 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
5955         if ((_res & 1) != 0) return;
5956         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5957         FREE((void*)_res);
5958         CResult_NonePeerHandleErrorZ_free(_res_conv);
5959 }
5960
5961 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
5962         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
5963         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5964         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
5965         return (long)ret_conv;
5966 }
5967
5968 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
5969         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5970         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
5971         return (long)ret_conv;
5972 }
5973
5974 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
5975         LDKPeerHandleError e_conv;
5976         e_conv.inner = (void*)(e & (~1));
5977         e_conv.is_owned = (e & 1) || (e == 0);
5978         e_conv = PeerHandleError_clone(&e_conv);
5979         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5980         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
5981         return (long)ret_conv;
5982 }
5983
5984 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
5985         if ((_res & 1) != 0) return;
5986         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5987         FREE((void*)_res);
5988         CResult_boolPeerHandleErrorZ_free(_res_conv);
5989 }
5990
5991 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
5992         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
5993         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5994         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
5995         return (long)ret_conv;
5996 }
5997
5998 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
5999         LDKInitFeatures o_conv;
6000         o_conv.inner = (void*)(o & (~1));
6001         o_conv.is_owned = (o & 1) || (o == 0);
6002         o_conv = InitFeatures_clone(&o_conv);
6003         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6004         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
6005         return (long)ret_conv;
6006 }
6007
6008 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
6009         LDKDecodeError e_conv;
6010         e_conv.inner = (void*)(e & (~1));
6011         e_conv.is_owned = (e & 1) || (e == 0);
6012         e_conv = DecodeError_clone(&e_conv);
6013         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6014         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
6015         return (long)ret_conv;
6016 }
6017
6018 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
6019         if ((_res & 1) != 0) return;
6020         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6021         FREE((void*)_res);
6022         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
6023 }
6024
6025 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
6026         LDKNodeFeatures o_conv;
6027         o_conv.inner = (void*)(o & (~1));
6028         o_conv.is_owned = (o & 1) || (o == 0);
6029         o_conv = NodeFeatures_clone(&o_conv);
6030         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6031         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
6032         return (long)ret_conv;
6033 }
6034
6035 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
6036         LDKDecodeError e_conv;
6037         e_conv.inner = (void*)(e & (~1));
6038         e_conv.is_owned = (e & 1) || (e == 0);
6039         e_conv = DecodeError_clone(&e_conv);
6040         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6041         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
6042         return (long)ret_conv;
6043 }
6044
6045 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
6046         if ((_res & 1) != 0) return;
6047         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6048         FREE((void*)_res);
6049         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
6050 }
6051
6052 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
6053         LDKChannelFeatures o_conv;
6054         o_conv.inner = (void*)(o & (~1));
6055         o_conv.is_owned = (o & 1) || (o == 0);
6056         o_conv = ChannelFeatures_clone(&o_conv);
6057         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6058         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
6059         return (long)ret_conv;
6060 }
6061
6062 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
6063         LDKDecodeError e_conv;
6064         e_conv.inner = (void*)(e & (~1));
6065         e_conv.is_owned = (e & 1) || (e == 0);
6066         e_conv = DecodeError_clone(&e_conv);
6067         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6068         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
6069         return (long)ret_conv;
6070 }
6071
6072 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
6073         if ((_res & 1) != 0) return;
6074         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6075         FREE((void*)_res);
6076         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
6077 }
6078
6079 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
6080         LDKChannelConfig o_conv;
6081         o_conv.inner = (void*)(o & (~1));
6082         o_conv.is_owned = (o & 1) || (o == 0);
6083         o_conv = ChannelConfig_clone(&o_conv);
6084         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6085         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6086         return (long)ret_conv;
6087 }
6088
6089 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
6090         LDKDecodeError e_conv;
6091         e_conv.inner = (void*)(e & (~1));
6092         e_conv.is_owned = (e & 1) || (e == 0);
6093         e_conv = DecodeError_clone(&e_conv);
6094         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6095         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6096         return (long)ret_conv;
6097 }
6098
6099 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
6100         if ((_res & 1) != 0) return;
6101         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6102         FREE((void*)_res);
6103         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6104 }
6105
6106 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
6107         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6108         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6109         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6110         return (long)ret_conv;
6111 }
6112
6113 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
6114         LDKDirectionalChannelInfo o_conv;
6115         o_conv.inner = (void*)(o & (~1));
6116         o_conv.is_owned = (o & 1) || (o == 0);
6117         o_conv = DirectionalChannelInfo_clone(&o_conv);
6118         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6119         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
6120         return (long)ret_conv;
6121 }
6122
6123 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
6124         LDKDecodeError e_conv;
6125         e_conv.inner = (void*)(e & (~1));
6126         e_conv.is_owned = (e & 1) || (e == 0);
6127         e_conv = DecodeError_clone(&e_conv);
6128         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6129         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
6130         return (long)ret_conv;
6131 }
6132
6133 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
6134         if ((_res & 1) != 0) return;
6135         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6136         FREE((void*)_res);
6137         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
6138 }
6139
6140 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6141         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
6142         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6143         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
6144         return (long)ret_conv;
6145 }
6146
6147 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
6148         LDKChannelInfo o_conv;
6149         o_conv.inner = (void*)(o & (~1));
6150         o_conv.is_owned = (o & 1) || (o == 0);
6151         o_conv = ChannelInfo_clone(&o_conv);
6152         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6153         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
6154         return (long)ret_conv;
6155 }
6156
6157 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
6158         LDKDecodeError e_conv;
6159         e_conv.inner = (void*)(e & (~1));
6160         e_conv.is_owned = (e & 1) || (e == 0);
6161         e_conv = DecodeError_clone(&e_conv);
6162         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6163         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
6164         return (long)ret_conv;
6165 }
6166
6167 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
6168         if ((_res & 1) != 0) return;
6169         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6170         FREE((void*)_res);
6171         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
6172 }
6173
6174 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6175         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
6176         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6177         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
6178         return (long)ret_conv;
6179 }
6180
6181 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6182         LDKRoutingFees o_conv;
6183         o_conv.inner = (void*)(o & (~1));
6184         o_conv.is_owned = (o & 1) || (o == 0);
6185         o_conv = RoutingFees_clone(&o_conv);
6186         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6187         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6188         return (long)ret_conv;
6189 }
6190
6191 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6192         LDKDecodeError e_conv;
6193         e_conv.inner = (void*)(e & (~1));
6194         e_conv.is_owned = (e & 1) || (e == 0);
6195         e_conv = DecodeError_clone(&e_conv);
6196         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6197         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6198         return (long)ret_conv;
6199 }
6200
6201 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6202         if ((_res & 1) != 0) return;
6203         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6204         FREE((void*)_res);
6205         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6206 }
6207
6208 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
6209         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
6210         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6211         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
6212         return (long)ret_conv;
6213 }
6214
6215 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
6216         LDKCVec_NetAddressZ _res_constr;
6217         _res_constr.datalen = *((uint32_t*)_res);
6218         if (_res_constr.datalen > 0)
6219                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6220         else
6221                 _res_constr.data = NULL;
6222         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6223         for (size_t m = 0; m < _res_constr.datalen; m++) {
6224                 uint32_t _res_conv_12 = _res_vals[m];
6225                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
6226                 FREE((void*)_res_conv_12);
6227                 _res_constr.data[m] = _res_conv_12_conv;
6228         }
6229         CVec_NetAddressZ_free(_res_constr);
6230 }
6231
6232 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6233         LDKNodeAnnouncementInfo o_conv;
6234         o_conv.inner = (void*)(o & (~1));
6235         o_conv.is_owned = (o & 1) || (o == 0);
6236         o_conv = NodeAnnouncementInfo_clone(&o_conv);
6237         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6238         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6239         return (long)ret_conv;
6240 }
6241
6242 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6243         LDKDecodeError e_conv;
6244         e_conv.inner = (void*)(e & (~1));
6245         e_conv.is_owned = (e & 1) || (e == 0);
6246         e_conv = DecodeError_clone(&e_conv);
6247         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6248         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6249         return (long)ret_conv;
6250 }
6251
6252 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6253         if ((_res & 1) != 0) return;
6254         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6255         FREE((void*)_res);
6256         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6257 }
6258
6259 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
6260         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
6261         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6262         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
6263         return (long)ret_conv;
6264 }
6265
6266 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
6267         LDKCVec_u64Z _res_constr;
6268         _res_constr.datalen = *((uint32_t*)_res);
6269         if (_res_constr.datalen > 0)
6270                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
6271         else
6272                 _res_constr.data = NULL;
6273         int64_t* _res_vals = (int64_t*)(_res + 4);
6274         for (size_t i = 0; i < _res_constr.datalen; i++) {
6275                 int64_t _res_conv_8 = _res_vals[i];
6276                 _res_constr.data[i] = _res_conv_8;
6277         }
6278         CVec_u64Z_free(_res_constr);
6279 }
6280
6281 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6282         LDKNodeInfo o_conv;
6283         o_conv.inner = (void*)(o & (~1));
6284         o_conv.is_owned = (o & 1) || (o == 0);
6285         o_conv = NodeInfo_clone(&o_conv);
6286         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6287         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6288         return (long)ret_conv;
6289 }
6290
6291 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6292         LDKDecodeError e_conv;
6293         e_conv.inner = (void*)(e & (~1));
6294         e_conv.is_owned = (e & 1) || (e == 0);
6295         e_conv = DecodeError_clone(&e_conv);
6296         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6297         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6298         return (long)ret_conv;
6299 }
6300
6301 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6302         if ((_res & 1) != 0) return;
6303         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6304         FREE((void*)_res);
6305         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6306 }
6307
6308 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
6309         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
6310         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6311         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
6312         return (long)ret_conv;
6313 }
6314
6315 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6316         LDKNetworkGraph o_conv;
6317         o_conv.inner = (void*)(o & (~1));
6318         o_conv.is_owned = (o & 1) || (o == 0);
6319         o_conv = NetworkGraph_clone(&o_conv);
6320         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6321         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6322         return (long)ret_conv;
6323 }
6324
6325 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6326         LDKDecodeError e_conv;
6327         e_conv.inner = (void*)(e & (~1));
6328         e_conv.is_owned = (e & 1) || (e == 0);
6329         e_conv = DecodeError_clone(&e_conv);
6330         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6331         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6332         return (long)ret_conv;
6333 }
6334
6335 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6336         if ((_res & 1) != 0) return;
6337         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
6338         FREE((void*)_res);
6339         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6340 }
6341
6342 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
6343         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
6344         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6345         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
6346         return (long)ret_conv;
6347 }
6348
6349 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
6350         LDKTransaction b_ref;
6351         b_ref.datalen = *((uint32_t*)b);
6352         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
6353         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6354         b_ref.data_is_owned = true;
6355         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6356         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
6357         return (long)ret_ref;
6358 }
6359
6360 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
6361         if ((_res & 1) != 0) return;
6362         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
6363         FREE((void*)_res);
6364         C2Tuple_usizeTransactionZ_free(_res_conv);
6365 }
6366
6367 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
6368         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
6369         _res_constr.datalen = *((uint32_t*)_res);
6370         if (_res_constr.datalen > 0)
6371                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6372         else
6373                 _res_constr.data = NULL;
6374         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6375         for (size_t e = 0; e < _res_constr.datalen; e++) {
6376                 uint32_t _res_conv_30 = _res_vals[e];
6377                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
6378                 FREE((void*)_res_conv_30);
6379                 _res_constr.data[e] = _res_conv_30_conv;
6380         }
6381         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
6382 }
6383
6384 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
6385         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6386         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
6387         return (long)ret_conv;
6388 }
6389
6390 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
6391         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
6392         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6393         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
6394         return (long)ret_conv;
6395 }
6396
6397 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
6398         if ((_res & 1) != 0) return;
6399         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
6400         FREE((void*)_res);
6401         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
6402 }
6403
6404 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
6405         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
6406         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6407         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
6408         return (long)ret_conv;
6409 }
6410
6411 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
6412         LDKCVec_MonitorEventZ _res_constr;
6413         _res_constr.datalen = *((uint32_t*)_res);
6414         if (_res_constr.datalen > 0)
6415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6416         else
6417                 _res_constr.data = NULL;
6418         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6419         for (size_t o = 0; o < _res_constr.datalen; o++) {
6420                 uint32_t _res_conv_14 = _res_vals[o];
6421                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
6422                 FREE((void*)_res_conv_14);
6423                 _res_constr.data[o] = _res_conv_14_conv;
6424         }
6425         CVec_MonitorEventZ_free(_res_constr);
6426 }
6427
6428 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
6429         LDKCVec_EventZ _res_constr;
6430         _res_constr.datalen = *((uint32_t*)_res);
6431         if (_res_constr.datalen > 0)
6432                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
6433         else
6434                 _res_constr.data = NULL;
6435         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6436         for (size_t h = 0; h < _res_constr.datalen; h++) {
6437                 uint32_t _res_conv_7 = _res_vals[h];
6438                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
6439                 FREE((void*)_res_conv_7);
6440                 _res_constr.data[h] = _res_conv_7_conv;
6441         }
6442         CVec_EventZ_free(_res_constr);
6443 }
6444
6445 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
6446         LDKOutPoint o_conv;
6447         o_conv.inner = (void*)(o & (~1));
6448         o_conv.is_owned = (o & 1) || (o == 0);
6449         o_conv = OutPoint_clone(&o_conv);
6450         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6451         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
6452         return (long)ret_conv;
6453 }
6454
6455 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
6456         LDKDecodeError e_conv;
6457         e_conv.inner = (void*)(e & (~1));
6458         e_conv.is_owned = (e & 1) || (e == 0);
6459         e_conv = DecodeError_clone(&e_conv);
6460         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6461         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
6462         return (long)ret_conv;
6463 }
6464
6465 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
6466         if ((_res & 1) != 0) return;
6467         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
6468         FREE((void*)_res);
6469         CResult_OutPointDecodeErrorZ_free(_res_conv);
6470 }
6471
6472 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
6473         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
6474         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6475         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
6476         return (long)ret_conv;
6477 }
6478
6479 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
6480         LDKChannelMonitorUpdate o_conv;
6481         o_conv.inner = (void*)(o & (~1));
6482         o_conv.is_owned = (o & 1) || (o == 0);
6483         o_conv = ChannelMonitorUpdate_clone(&o_conv);
6484         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6485         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
6486         return (long)ret_conv;
6487 }
6488
6489 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
6490         LDKDecodeError e_conv;
6491         e_conv.inner = (void*)(e & (~1));
6492         e_conv.is_owned = (e & 1) || (e == 0);
6493         e_conv = DecodeError_clone(&e_conv);
6494         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6495         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
6496         return (long)ret_conv;
6497 }
6498
6499 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
6500         if ((_res & 1) != 0) return;
6501         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6502         FREE((void*)_res);
6503         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
6504 }
6505
6506 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
6507         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
6508         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6509         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
6510         return (long)ret_conv;
6511 }
6512
6513 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
6514         LDKHTLCUpdate o_conv;
6515         o_conv.inner = (void*)(o & (~1));
6516         o_conv.is_owned = (o & 1) || (o == 0);
6517         o_conv = HTLCUpdate_clone(&o_conv);
6518         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6519         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
6520         return (long)ret_conv;
6521 }
6522
6523 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
6524         LDKDecodeError e_conv;
6525         e_conv.inner = (void*)(e & (~1));
6526         e_conv.is_owned = (e & 1) || (e == 0);
6527         e_conv = DecodeError_clone(&e_conv);
6528         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6529         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
6530         return (long)ret_conv;
6531 }
6532
6533 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
6534         if ((_res & 1) != 0) return;
6535         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6536         FREE((void*)_res);
6537         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
6538 }
6539
6540 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
6541         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
6542         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6543         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
6544         return (long)ret_conv;
6545 }
6546
6547 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
6548         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6549         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
6550         return (long)ret_conv;
6551 }
6552
6553 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
6554         LDKMonitorUpdateError e_conv;
6555         e_conv.inner = (void*)(e & (~1));
6556         e_conv.is_owned = (e & 1) || (e == 0);
6557         e_conv = MonitorUpdateError_clone(&e_conv);
6558         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6559         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
6560         return (long)ret_conv;
6561 }
6562
6563 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
6564         if ((_res & 1) != 0) return;
6565         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
6566         FREE((void*)_res);
6567         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
6568 }
6569
6570 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
6571         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
6572         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6573         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
6574         return (long)ret_conv;
6575 }
6576
6577 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
6578         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
6579         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6580         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
6581         return (long)ret_ref;
6582 }
6583
6584 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
6585         LDKOutPoint a_conv;
6586         a_conv.inner = (void*)(a & (~1));
6587         a_conv.is_owned = (a & 1) || (a == 0);
6588         a_conv = OutPoint_clone(&a_conv);
6589         LDKCVec_u8Z b_ref;
6590         b_ref.datalen = *((uint32_t*)b);
6591         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6592         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6593         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6594         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
6595         return (long)ret_ref;
6596 }
6597
6598 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
6599         if ((_res & 1) != 0) return;
6600         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
6601         FREE((void*)_res);
6602         C2Tuple_OutPointScriptZ_free(_res_conv);
6603 }
6604
6605 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
6606         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
6607         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6608         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
6609         return (long)ret_ref;
6610 }
6611
6612 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
6613         LDKCVec_u8Z b_ref;
6614         b_ref.datalen = *((uint32_t*)b);
6615         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6616         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6617         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6618         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
6619         return (long)ret_ref;
6620 }
6621
6622 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
6623         if ((_res & 1) != 0) return;
6624         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
6625         FREE((void*)_res);
6626         C2Tuple_u32ScriptZ_free(_res_conv);
6627 }
6628
6629 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
6630         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
6631         _res_constr.datalen = *((uint32_t*)_res);
6632         if (_res_constr.datalen > 0)
6633                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6634         else
6635                 _res_constr.data = NULL;
6636         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6637         for (size_t e = 0; e < _res_constr.datalen; e++) {
6638                 uint32_t _res_conv_30 = _res_vals[e];
6639                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
6640                 FREE((void*)_res_conv_30);
6641                 _res_constr.data[e] = _res_conv_30_conv;
6642         }
6643         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
6644 }
6645
6646 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
6647         LDKThirtyTwoBytes a_ref;
6648         CHECK(*((uint32_t*)a) == 32);
6649         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6650         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
6651         b_constr.datalen = *((uint32_t*)b);
6652         if (b_constr.datalen > 0)
6653                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6654         else
6655                 b_constr.data = NULL;
6656         uint32_t* b_vals = (uint32_t*)(b + 4);
6657         for (size_t e = 0; e < b_constr.datalen; e++) {
6658                 uint32_t b_conv_30 = b_vals[e];
6659                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
6660                 FREE((void*)b_conv_30);
6661                 b_constr.data[e] = b_conv_30_conv;
6662         }
6663         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
6664         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
6665         return (long)ret_ref;
6666 }
6667
6668 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
6669         if ((_res & 1) != 0) return;
6670         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
6671         FREE((void*)_res);
6672         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
6673 }
6674
6675 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
6676         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
6677         _res_constr.datalen = *((uint32_t*)_res);
6678         if (_res_constr.datalen > 0)
6679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
6680         else
6681                 _res_constr.data = NULL;
6682         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6683         for (size_t c = 0; c < _res_constr.datalen; c++) {
6684                 uint32_t _res_conv_54 = _res_vals[c];
6685                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
6686                 FREE((void*)_res_conv_54);
6687                 _res_constr.data[c] = _res_conv_54_conv;
6688         }
6689         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
6690 }
6691
6692 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
6693         LDKCVec_TransactionZ _res_constr;
6694         _res_constr.datalen = *((uint32_t*)_res);
6695         if (_res_constr.datalen > 0)
6696                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6697         else
6698                 _res_constr.data = NULL;
6699         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6700         for (size_t m = 0; m < _res_constr.datalen; m++) {
6701                 int8_tArray _res_conv_12 = _res_vals[m];
6702                 LDKTransaction _res_conv_12_ref;
6703                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
6704                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
6705                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
6706                 _res_conv_12_ref.data_is_owned = true;
6707                 _res_constr.data[m] = _res_conv_12_ref;
6708         }
6709         CVec_TransactionZ_free(_res_constr);
6710 }
6711
6712 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
6713         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
6714         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6715         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
6716         return (long)ret_ref;
6717 }
6718
6719 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
6720         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
6721         FREE((void*)b);
6722         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6723         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
6724         return (long)ret_ref;
6725 }
6726
6727 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
6728         if ((_res & 1) != 0) return;
6729         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
6730         FREE((void*)_res);
6731         C2Tuple_u32TxOutZ_free(_res_conv);
6732 }
6733
6734 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
6735         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
6736         _res_constr.datalen = *((uint32_t*)_res);
6737         if (_res_constr.datalen > 0)
6738                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6739         else
6740                 _res_constr.data = NULL;
6741         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6742         for (size_t z = 0; z < _res_constr.datalen; z++) {
6743                 uint32_t _res_conv_25 = _res_vals[z];
6744                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
6745                 FREE((void*)_res_conv_25);
6746                 _res_constr.data[z] = _res_conv_25_conv;
6747         }
6748         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
6749 }
6750
6751 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
6752         LDKThirtyTwoBytes a_ref;
6753         CHECK(*((uint32_t*)a) == 32);
6754         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6755         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
6756         b_constr.datalen = *((uint32_t*)b);
6757         if (b_constr.datalen > 0)
6758                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6759         else
6760                 b_constr.data = NULL;
6761         uint32_t* b_vals = (uint32_t*)(b + 4);
6762         for (size_t z = 0; z < b_constr.datalen; z++) {
6763                 uint32_t b_conv_25 = b_vals[z];
6764                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
6765                 FREE((void*)b_conv_25);
6766                 b_constr.data[z] = b_conv_25_conv;
6767         }
6768         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
6769         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
6770         return (long)ret_ref;
6771 }
6772
6773 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
6774         if ((_res & 1) != 0) return;
6775         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
6776         FREE((void*)_res);
6777         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
6778 }
6779
6780 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
6781         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
6782         _res_constr.datalen = *((uint32_t*)_res);
6783         if (_res_constr.datalen > 0)
6784                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
6785         else
6786                 _res_constr.data = NULL;
6787         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6788         for (size_t x = 0; x < _res_constr.datalen; x++) {
6789                 uint32_t _res_conv_49 = _res_vals[x];
6790                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
6791                 FREE((void*)_res_conv_49);
6792                 _res_constr.data[x] = _res_conv_49_conv;
6793         }
6794         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
6795 }
6796
6797 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
6798         LDKThirtyTwoBytes a_ref;
6799         CHECK(*((uint32_t*)a) == 32);
6800         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6801         LDKChannelMonitor b_conv;
6802         b_conv.inner = (void*)(b & (~1));
6803         b_conv.is_owned = (b & 1) || (b == 0);
6804         b_conv = ChannelMonitor_clone(&b_conv);
6805         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6806         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
6807         return (long)ret_ref;
6808 }
6809
6810 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
6811         if ((_res & 1) != 0) return;
6812         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
6813         FREE((void*)_res);
6814         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
6815 }
6816
6817 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
6818         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
6819         FREE((void*)o);
6820         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6821         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
6822         return (long)ret_conv;
6823 }
6824
6825 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
6826         LDKDecodeError e_conv;
6827         e_conv.inner = (void*)(e & (~1));
6828         e_conv.is_owned = (e & 1) || (e == 0);
6829         e_conv = DecodeError_clone(&e_conv);
6830         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6831         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
6832         return (long)ret_conv;
6833 }
6834
6835 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
6836         if ((_res & 1) != 0) return;
6837         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
6838         FREE((void*)_res);
6839         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
6840 }
6841
6842 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
6843         LDKCVec_SpendableOutputDescriptorZ _res_constr;
6844         _res_constr.datalen = *((uint32_t*)_res);
6845         if (_res_constr.datalen > 0)
6846                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
6847         else
6848                 _res_constr.data = NULL;
6849         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6850         for (size_t b = 0; b < _res_constr.datalen; b++) {
6851                 uint32_t _res_conv_27 = _res_vals[b];
6852                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
6853                 FREE((void*)_res_conv_27);
6854                 _res_constr.data[b] = _res_conv_27_conv;
6855         }
6856         CVec_SpendableOutputDescriptorZ_free(_res_constr);
6857 }
6858
6859 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
6860         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
6861         FREE((void*)o);
6862         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6863         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
6864         return (long)ret_conv;
6865 }
6866
6867 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
6868         LDKAccessError e_conv = LDKAccessError_from_js(e);
6869         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6870         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
6871         return (long)ret_conv;
6872 }
6873
6874 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
6875         if ((_res & 1) != 0) return;
6876         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
6877         FREE((void*)_res);
6878         CResult_TxOutAccessErrorZ_free(_res_conv);
6879 }
6880
6881 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
6882         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
6883         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6884         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
6885         return (long)ret_conv;
6886 }
6887
6888 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
6889         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6890         *ret_conv = CResult_NoneAPIErrorZ_ok();
6891         return (long)ret_conv;
6892 }
6893
6894 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
6895         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
6896         FREE((void*)e);
6897         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6898         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
6899         return (long)ret_conv;
6900 }
6901
6902 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
6903         if ((_res & 1) != 0) return;
6904         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
6905         FREE((void*)_res);
6906         CResult_NoneAPIErrorZ_free(_res_conv);
6907 }
6908
6909 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
6910         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
6911         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6912         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
6913         return (long)ret_conv;
6914 }
6915
6916 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
6917         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
6918         _res_constr.datalen = *((uint32_t*)_res);
6919         if (_res_constr.datalen > 0)
6920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
6921         else
6922                 _res_constr.data = NULL;
6923         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6924         for (size_t w = 0; w < _res_constr.datalen; w++) {
6925                 uint32_t _res_conv_22 = _res_vals[w];
6926                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
6927                 FREE((void*)_res_conv_22);
6928                 _res_constr.data[w] = _res_conv_22_conv;
6929         }
6930         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
6931 }
6932
6933 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
6934         LDKCVec_APIErrorZ _res_constr;
6935         _res_constr.datalen = *((uint32_t*)_res);
6936         if (_res_constr.datalen > 0)
6937                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
6938         else
6939                 _res_constr.data = NULL;
6940         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6941         for (size_t k = 0; k < _res_constr.datalen; k++) {
6942                 uint32_t _res_conv_10 = _res_vals[k];
6943                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
6944                 FREE((void*)_res_conv_10);
6945                 _res_constr.data[k] = _res_conv_10_conv;
6946         }
6947         CVec_APIErrorZ_free(_res_constr);
6948 }
6949
6950 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
6951         LDKCVec_ChannelDetailsZ _res_constr;
6952         _res_constr.datalen = *((uint32_t*)_res);
6953         if (_res_constr.datalen > 0)
6954                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6955         else
6956                 _res_constr.data = NULL;
6957         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6958         for (size_t q = 0; q < _res_constr.datalen; q++) {
6959                 uint32_t _res_conv_16 = _res_vals[q];
6960                 LDKChannelDetails _res_conv_16_conv;
6961                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
6962                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
6963                 _res_constr.data[q] = _res_conv_16_conv;
6964         }
6965         CVec_ChannelDetailsZ_free(_res_constr);
6966 }
6967
6968 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
6969         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6970         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
6971         return (long)ret_conv;
6972 }
6973
6974 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
6975         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
6976         FREE((void*)e);
6977         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6978         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
6979         return (long)ret_conv;
6980 }
6981
6982 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
6983         if ((_res & 1) != 0) return;
6984         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
6985         FREE((void*)_res);
6986         CResult_NonePaymentSendFailureZ_free(_res_conv);
6987 }
6988
6989 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
6990         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
6991         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6992         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
6993         return (long)ret_conv;
6994 }
6995
6996 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
6997         LDKCVec_ChannelMonitorZ _res_constr;
6998         _res_constr.datalen = *((uint32_t*)_res);
6999         if (_res_constr.datalen > 0)
7000                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7001         else
7002                 _res_constr.data = NULL;
7003         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7004         for (size_t q = 0; q < _res_constr.datalen; q++) {
7005                 uint32_t _res_conv_16 = _res_vals[q];
7006                 LDKChannelMonitor _res_conv_16_conv;
7007                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7008                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7009                 _res_constr.data[q] = _res_conv_16_conv;
7010         }
7011         CVec_ChannelMonitorZ_free(_res_constr);
7012 }
7013
7014 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
7015         LDKThirtyTwoBytes a_ref;
7016         CHECK(*((uint32_t*)a) == 32);
7017         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7018         LDKChannelManager b_conv;
7019         b_conv.inner = (void*)(b & (~1));
7020         b_conv.is_owned = (b & 1) || (b == 0);
7021         // Warning: we need a move here but no clone is available for LDKChannelManager
7022         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
7023         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
7024         return (long)ret_ref;
7025 }
7026
7027 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
7028         if ((_res & 1) != 0) return;
7029         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
7030         FREE((void*)_res);
7031         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
7032 }
7033
7034 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
7035         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
7036         FREE((void*)o);
7037         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7038         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
7039         return (long)ret_conv;
7040 }
7041
7042 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
7043         LDKDecodeError e_conv;
7044         e_conv.inner = (void*)(e & (~1));
7045         e_conv.is_owned = (e & 1) || (e == 0);
7046         e_conv = DecodeError_clone(&e_conv);
7047         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7048         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
7049         return (long)ret_conv;
7050 }
7051
7052 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
7053         if ((_res & 1) != 0) return;
7054         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7055         FREE((void*)_res);
7056         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
7057 }
7058
7059 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7060         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7061         FREE((void*)o);
7062         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7063         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7064         return (long)ret_conv;
7065 }
7066
7067 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7068         LDKDecodeError e_conv;
7069         e_conv.inner = (void*)(e & (~1));
7070         e_conv.is_owned = (e & 1) || (e == 0);
7071         e_conv = DecodeError_clone(&e_conv);
7072         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7073         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7074         return (long)ret_conv;
7075 }
7076
7077 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7078         if ((_res & 1) != 0) return;
7079         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7080         FREE((void*)_res);
7081         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7082 }
7083
7084 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7085         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7086         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7087         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7088         return (long)ret_conv;
7089 }
7090
7091 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7092         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7093         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7094         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7095         return (long)ret_ref;
7096 }
7097
7098 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7099         LDKSignature a_ref;
7100         CHECK(*((uint32_t*)a) == 64);
7101         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7102         LDKCVec_SignatureZ b_constr;
7103         b_constr.datalen = *((uint32_t*)b);
7104         if (b_constr.datalen > 0)
7105                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7106         else
7107                 b_constr.data = NULL;
7108         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7109         for (size_t m = 0; m < b_constr.datalen; m++) {
7110                 int8_tArray b_conv_12 = b_vals[m];
7111                 LDKSignature b_conv_12_ref;
7112                 CHECK(*((uint32_t*)b_conv_12) == 64);
7113                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7114                 b_constr.data[m] = b_conv_12_ref;
7115         }
7116         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7117         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7118         return (long)ret_ref;
7119 }
7120
7121 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7122         if ((_res & 1) != 0) return;
7123         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7124         FREE((void*)_res);
7125         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7126 }
7127
7128 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7129         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7130         FREE((void*)o);
7131         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7132         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7133         return (long)ret_conv;
7134 }
7135
7136 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7137         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7138         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7139         return (long)ret_conv;
7140 }
7141
7142 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7143         if ((_res & 1) != 0) return;
7144         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7145         FREE((void*)_res);
7146         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7147 }
7148
7149 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7150         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7151         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7152         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7153         return (long)ret_conv;
7154 }
7155
7156 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7157         LDKSignature o_ref;
7158         CHECK(*((uint32_t*)o) == 64);
7159         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7160         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7161         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7162         return (long)ret_conv;
7163 }
7164
7165 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7166         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7167         *ret_conv = CResult_SignatureNoneZ_err();
7168         return (long)ret_conv;
7169 }
7170
7171 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7172         if ((_res & 1) != 0) return;
7173         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7174         FREE((void*)_res);
7175         CResult_SignatureNoneZ_free(_res_conv);
7176 }
7177
7178 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7179         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7180         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7181         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7182         return (long)ret_conv;
7183 }
7184
7185 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7186         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7187         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7188         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7189         return (long)ret_conv;
7190 }
7191
7192 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7193         LDKDecodeError e_conv;
7194         e_conv.inner = (void*)(e & (~1));
7195         e_conv.is_owned = (e & 1) || (e == 0);
7196         e_conv = DecodeError_clone(&e_conv);
7197         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7198         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7199         return (long)ret_conv;
7200 }
7201
7202 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7203         if ((_res & 1) != 0) return;
7204         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7205         FREE((void*)_res);
7206         CResult_SignDecodeErrorZ_free(_res_conv);
7207 }
7208
7209 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7210         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7211         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7212         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7213         return (long)ret_conv;
7214 }
7215
7216 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7217         LDKCVec_CVec_u8ZZ _res_constr;
7218         _res_constr.datalen = *((uint32_t*)_res);
7219         if (_res_constr.datalen > 0)
7220                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7221         else
7222                 _res_constr.data = NULL;
7223         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7224         for (size_t m = 0; m < _res_constr.datalen; m++) {
7225                 int8_tArray _res_conv_12 = _res_vals[m];
7226                 LDKCVec_u8Z _res_conv_12_ref;
7227                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7228                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7229                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7230                 _res_constr.data[m] = _res_conv_12_ref;
7231         }
7232         CVec_CVec_u8ZZ_free(_res_constr);
7233 }
7234
7235 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7236         LDKCVec_CVec_u8ZZ o_constr;
7237         o_constr.datalen = *((uint32_t*)o);
7238         if (o_constr.datalen > 0)
7239                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7240         else
7241                 o_constr.data = NULL;
7242         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7243         for (size_t m = 0; m < o_constr.datalen; m++) {
7244                 int8_tArray o_conv_12 = o_vals[m];
7245                 LDKCVec_u8Z o_conv_12_ref;
7246                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7247                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7248                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7249                 o_constr.data[m] = o_conv_12_ref;
7250         }
7251         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7252         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7253         return (long)ret_conv;
7254 }
7255
7256 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7257         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7258         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7259         return (long)ret_conv;
7260 }
7261
7262 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7263         if ((_res & 1) != 0) return;
7264         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7265         FREE((void*)_res);
7266         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7267 }
7268
7269 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7270         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7271         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7272         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7273         return (long)ret_conv;
7274 }
7275
7276 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7277         LDKInMemorySigner o_conv;
7278         o_conv.inner = (void*)(o & (~1));
7279         o_conv.is_owned = (o & 1) || (o == 0);
7280         o_conv = InMemorySigner_clone(&o_conv);
7281         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7282         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7283         return (long)ret_conv;
7284 }
7285
7286 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7287         LDKDecodeError e_conv;
7288         e_conv.inner = (void*)(e & (~1));
7289         e_conv.is_owned = (e & 1) || (e == 0);
7290         e_conv = DecodeError_clone(&e_conv);
7291         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7292         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7293         return (long)ret_conv;
7294 }
7295
7296 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7297         if ((_res & 1) != 0) return;
7298         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7299         FREE((void*)_res);
7300         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7301 }
7302
7303 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7304         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7305         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7306         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7307         return (long)ret_conv;
7308 }
7309
7310 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7311         LDKCVec_TxOutZ _res_constr;
7312         _res_constr.datalen = *((uint32_t*)_res);
7313         if (_res_constr.datalen > 0)
7314                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7315         else
7316                 _res_constr.data = NULL;
7317         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7318         for (size_t h = 0; h < _res_constr.datalen; h++) {
7319                 uint32_t _res_conv_7 = _res_vals[h];
7320                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7321                 FREE((void*)_res_conv_7);
7322                 _res_constr.data[h] = _res_conv_7_conv;
7323         }
7324         CVec_TxOutZ_free(_res_constr);
7325 }
7326
7327 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7328         LDKTransaction o_ref;
7329         o_ref.datalen = *((uint32_t*)o);
7330         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7331         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7332         o_ref.data_is_owned = true;
7333         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7334         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7335         return (long)ret_conv;
7336 }
7337
7338 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7339         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7340         *ret_conv = CResult_TransactionNoneZ_err();
7341         return (long)ret_conv;
7342 }
7343
7344 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7345         if ((_res & 1) != 0) return;
7346         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7347         FREE((void*)_res);
7348         CResult_TransactionNoneZ_free(_res_conv);
7349 }
7350
7351 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7352         LDKCVec_RouteHopZ _res_constr;
7353         _res_constr.datalen = *((uint32_t*)_res);
7354         if (_res_constr.datalen > 0)
7355                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7356         else
7357                 _res_constr.data = NULL;
7358         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7359         for (size_t k = 0; k < _res_constr.datalen; k++) {
7360                 uint32_t _res_conv_10 = _res_vals[k];
7361                 LDKRouteHop _res_conv_10_conv;
7362                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7363                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7364                 _res_constr.data[k] = _res_conv_10_conv;
7365         }
7366         CVec_RouteHopZ_free(_res_constr);
7367 }
7368
7369 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7370         LDKCVec_CVec_RouteHopZZ _res_constr;
7371         _res_constr.datalen = *((uint32_t*)_res);
7372         if (_res_constr.datalen > 0)
7373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7374         else
7375                 _res_constr.data = NULL;
7376         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7377         for (size_t m = 0; m < _res_constr.datalen; m++) {
7378                 uint32_tArray _res_conv_12 = _res_vals[m];
7379                 LDKCVec_RouteHopZ _res_conv_12_constr;
7380                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7381                 if (_res_conv_12_constr.datalen > 0)
7382                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7383                 else
7384                         _res_conv_12_constr.data = NULL;
7385                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7386                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7387                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7388                         LDKRouteHop _res_conv_12_conv_10_conv;
7389                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7390                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7391                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7392                 }
7393                 _res_constr.data[m] = _res_conv_12_constr;
7394         }
7395         CVec_CVec_RouteHopZZ_free(_res_constr);
7396 }
7397
7398 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7399         LDKRoute o_conv;
7400         o_conv.inner = (void*)(o & (~1));
7401         o_conv.is_owned = (o & 1) || (o == 0);
7402         o_conv = Route_clone(&o_conv);
7403         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7404         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7405         return (long)ret_conv;
7406 }
7407
7408 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7409         LDKDecodeError e_conv;
7410         e_conv.inner = (void*)(e & (~1));
7411         e_conv.is_owned = (e & 1) || (e == 0);
7412         e_conv = DecodeError_clone(&e_conv);
7413         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7414         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7415         return (long)ret_conv;
7416 }
7417
7418 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7419         if ((_res & 1) != 0) return;
7420         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7421         FREE((void*)_res);
7422         CResult_RouteDecodeErrorZ_free(_res_conv);
7423 }
7424
7425 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7426         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7427         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7428         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7429         return (long)ret_conv;
7430 }
7431
7432 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7433         LDKCVec_RouteHintZ _res_constr;
7434         _res_constr.datalen = *((uint32_t*)_res);
7435         if (_res_constr.datalen > 0)
7436                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7437         else
7438                 _res_constr.data = NULL;
7439         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7440         for (size_t l = 0; l < _res_constr.datalen; l++) {
7441                 uint32_t _res_conv_11 = _res_vals[l];
7442                 LDKRouteHint _res_conv_11_conv;
7443                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7444                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7445                 _res_constr.data[l] = _res_conv_11_conv;
7446         }
7447         CVec_RouteHintZ_free(_res_constr);
7448 }
7449
7450 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7451         LDKRoute o_conv;
7452         o_conv.inner = (void*)(o & (~1));
7453         o_conv.is_owned = (o & 1) || (o == 0);
7454         o_conv = Route_clone(&o_conv);
7455         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7456         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7457         return (long)ret_conv;
7458 }
7459
7460 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7461         LDKLightningError e_conv;
7462         e_conv.inner = (void*)(e & (~1));
7463         e_conv.is_owned = (e & 1) || (e == 0);
7464         e_conv = LightningError_clone(&e_conv);
7465         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7466         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7467         return (long)ret_conv;
7468 }
7469
7470 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7471         if ((_res & 1) != 0) return;
7472         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7473         FREE((void*)_res);
7474         CResult_RouteLightningErrorZ_free(_res_conv);
7475 }
7476
7477 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7478         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7479         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7480         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7481         return (long)ret_conv;
7482 }
7483
7484 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
7485         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
7486         FREE((void*)o);
7487         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7488         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
7489         return (long)ret_conv;
7490 }
7491
7492 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
7493         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7494         *ret_conv = CResult_NetAddressu8Z_err(e);
7495         return (long)ret_conv;
7496 }
7497
7498 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
7499         if ((_res & 1) != 0) return;
7500         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
7501         FREE((void*)_res);
7502         CResult_NetAddressu8Z_free(_res_conv);
7503 }
7504
7505 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
7506         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
7507         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7508         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
7509         return (long)ret_conv;
7510 }
7511
7512 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
7513         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
7514         FREE((void*)o);
7515         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7516         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
7517         return (long)ret_conv;
7518 }
7519
7520 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
7521         LDKDecodeError e_conv;
7522         e_conv.inner = (void*)(e & (~1));
7523         e_conv.is_owned = (e & 1) || (e == 0);
7524         e_conv = DecodeError_clone(&e_conv);
7525         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7526         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
7527         return (long)ret_conv;
7528 }
7529
7530 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
7531         if ((_res & 1) != 0) return;
7532         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7533         FREE((void*)_res);
7534         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
7535 }
7536
7537 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
7538         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
7539         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7540         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
7541         return (long)ret_conv;
7542 }
7543
7544 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
7545         LDKCVec_UpdateAddHTLCZ _res_constr;
7546         _res_constr.datalen = *((uint32_t*)_res);
7547         if (_res_constr.datalen > 0)
7548                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
7549         else
7550                 _res_constr.data = NULL;
7551         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7552         for (size_t p = 0; p < _res_constr.datalen; p++) {
7553                 uint32_t _res_conv_15 = _res_vals[p];
7554                 LDKUpdateAddHTLC _res_conv_15_conv;
7555                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
7556                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
7557                 _res_constr.data[p] = _res_conv_15_conv;
7558         }
7559         CVec_UpdateAddHTLCZ_free(_res_constr);
7560 }
7561
7562 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
7563         LDKCVec_UpdateFulfillHTLCZ _res_constr;
7564         _res_constr.datalen = *((uint32_t*)_res);
7565         if (_res_constr.datalen > 0)
7566                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
7567         else
7568                 _res_constr.data = NULL;
7569         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7570         for (size_t t = 0; t < _res_constr.datalen; t++) {
7571                 uint32_t _res_conv_19 = _res_vals[t];
7572                 LDKUpdateFulfillHTLC _res_conv_19_conv;
7573                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
7574                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
7575                 _res_constr.data[t] = _res_conv_19_conv;
7576         }
7577         CVec_UpdateFulfillHTLCZ_free(_res_constr);
7578 }
7579
7580 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
7581         LDKCVec_UpdateFailHTLCZ _res_constr;
7582         _res_constr.datalen = *((uint32_t*)_res);
7583         if (_res_constr.datalen > 0)
7584                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
7585         else
7586                 _res_constr.data = NULL;
7587         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7588         for (size_t q = 0; q < _res_constr.datalen; q++) {
7589                 uint32_t _res_conv_16 = _res_vals[q];
7590                 LDKUpdateFailHTLC _res_conv_16_conv;
7591                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7592                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7593                 _res_constr.data[q] = _res_conv_16_conv;
7594         }
7595         CVec_UpdateFailHTLCZ_free(_res_constr);
7596 }
7597
7598 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
7599         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
7600         _res_constr.datalen = *((uint32_t*)_res);
7601         if (_res_constr.datalen > 0)
7602                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
7603         else
7604                 _res_constr.data = NULL;
7605         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7606         for (size_t z = 0; z < _res_constr.datalen; z++) {
7607                 uint32_t _res_conv_25 = _res_vals[z];
7608                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
7609                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
7610                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
7611                 _res_constr.data[z] = _res_conv_25_conv;
7612         }
7613         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
7614 }
7615
7616 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
7617         LDKAcceptChannel o_conv;
7618         o_conv.inner = (void*)(o & (~1));
7619         o_conv.is_owned = (o & 1) || (o == 0);
7620         o_conv = AcceptChannel_clone(&o_conv);
7621         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7622         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
7623         return (long)ret_conv;
7624 }
7625
7626 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
7627         LDKDecodeError e_conv;
7628         e_conv.inner = (void*)(e & (~1));
7629         e_conv.is_owned = (e & 1) || (e == 0);
7630         e_conv = DecodeError_clone(&e_conv);
7631         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7632         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
7633         return (long)ret_conv;
7634 }
7635
7636 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
7637         if ((_res & 1) != 0) return;
7638         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7639         FREE((void*)_res);
7640         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
7641 }
7642
7643 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
7644         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
7645         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7646         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
7647         return (long)ret_conv;
7648 }
7649
7650 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
7651         LDKAnnouncementSignatures o_conv;
7652         o_conv.inner = (void*)(o & (~1));
7653         o_conv.is_owned = (o & 1) || (o == 0);
7654         o_conv = AnnouncementSignatures_clone(&o_conv);
7655         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7656         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
7657         return (long)ret_conv;
7658 }
7659
7660 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
7661         LDKDecodeError e_conv;
7662         e_conv.inner = (void*)(e & (~1));
7663         e_conv.is_owned = (e & 1) || (e == 0);
7664         e_conv = DecodeError_clone(&e_conv);
7665         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7666         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
7667         return (long)ret_conv;
7668 }
7669
7670 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
7671         if ((_res & 1) != 0) return;
7672         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7673         FREE((void*)_res);
7674         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
7675 }
7676
7677 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
7678         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
7679         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7680         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
7681         return (long)ret_conv;
7682 }
7683
7684 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
7685         LDKChannelReestablish o_conv;
7686         o_conv.inner = (void*)(o & (~1));
7687         o_conv.is_owned = (o & 1) || (o == 0);
7688         o_conv = ChannelReestablish_clone(&o_conv);
7689         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7690         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
7691         return (long)ret_conv;
7692 }
7693
7694 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
7695         LDKDecodeError e_conv;
7696         e_conv.inner = (void*)(e & (~1));
7697         e_conv.is_owned = (e & 1) || (e == 0);
7698         e_conv = DecodeError_clone(&e_conv);
7699         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7700         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
7701         return (long)ret_conv;
7702 }
7703
7704 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
7705         if ((_res & 1) != 0) return;
7706         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
7707         FREE((void*)_res);
7708         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
7709 }
7710
7711 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
7712         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
7713         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7714         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
7715         return (long)ret_conv;
7716 }
7717
7718 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
7719         LDKClosingSigned o_conv;
7720         o_conv.inner = (void*)(o & (~1));
7721         o_conv.is_owned = (o & 1) || (o == 0);
7722         o_conv = ClosingSigned_clone(&o_conv);
7723         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7724         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
7725         return (long)ret_conv;
7726 }
7727
7728 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
7729         LDKDecodeError e_conv;
7730         e_conv.inner = (void*)(e & (~1));
7731         e_conv.is_owned = (e & 1) || (e == 0);
7732         e_conv = DecodeError_clone(&e_conv);
7733         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7734         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
7735         return (long)ret_conv;
7736 }
7737
7738 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
7739         if ((_res & 1) != 0) return;
7740         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7741         FREE((void*)_res);
7742         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
7743 }
7744
7745 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
7746         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
7747         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7748         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
7749         return (long)ret_conv;
7750 }
7751
7752 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
7753         LDKCommitmentSigned o_conv;
7754         o_conv.inner = (void*)(o & (~1));
7755         o_conv.is_owned = (o & 1) || (o == 0);
7756         o_conv = CommitmentSigned_clone(&o_conv);
7757         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7758         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
7759         return (long)ret_conv;
7760 }
7761
7762 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
7763         LDKDecodeError e_conv;
7764         e_conv.inner = (void*)(e & (~1));
7765         e_conv.is_owned = (e & 1) || (e == 0);
7766         e_conv = DecodeError_clone(&e_conv);
7767         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7768         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
7769         return (long)ret_conv;
7770 }
7771
7772 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
7773         if ((_res & 1) != 0) return;
7774         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7775         FREE((void*)_res);
7776         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
7777 }
7778
7779 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
7780         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
7781         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7782         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
7783         return (long)ret_conv;
7784 }
7785
7786 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
7787         LDKFundingCreated o_conv;
7788         o_conv.inner = (void*)(o & (~1));
7789         o_conv.is_owned = (o & 1) || (o == 0);
7790         o_conv = FundingCreated_clone(&o_conv);
7791         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7792         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
7793         return (long)ret_conv;
7794 }
7795
7796 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
7797         LDKDecodeError e_conv;
7798         e_conv.inner = (void*)(e & (~1));
7799         e_conv.is_owned = (e & 1) || (e == 0);
7800         e_conv = DecodeError_clone(&e_conv);
7801         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7802         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
7803         return (long)ret_conv;
7804 }
7805
7806 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
7807         if ((_res & 1) != 0) return;
7808         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7809         FREE((void*)_res);
7810         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
7811 }
7812
7813 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
7814         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
7815         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7816         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
7817         return (long)ret_conv;
7818 }
7819
7820 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
7821         LDKFundingSigned o_conv;
7822         o_conv.inner = (void*)(o & (~1));
7823         o_conv.is_owned = (o & 1) || (o == 0);
7824         o_conv = FundingSigned_clone(&o_conv);
7825         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7826         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
7827         return (long)ret_conv;
7828 }
7829
7830 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
7831         LDKDecodeError e_conv;
7832         e_conv.inner = (void*)(e & (~1));
7833         e_conv.is_owned = (e & 1) || (e == 0);
7834         e_conv = DecodeError_clone(&e_conv);
7835         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7836         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
7837         return (long)ret_conv;
7838 }
7839
7840 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
7841         if ((_res & 1) != 0) return;
7842         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7843         FREE((void*)_res);
7844         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
7845 }
7846
7847 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
7848         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
7849         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7850         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
7851         return (long)ret_conv;
7852 }
7853
7854 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
7855         LDKFundingLocked o_conv;
7856         o_conv.inner = (void*)(o & (~1));
7857         o_conv.is_owned = (o & 1) || (o == 0);
7858         o_conv = FundingLocked_clone(&o_conv);
7859         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7860         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
7861         return (long)ret_conv;
7862 }
7863
7864 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
7865         LDKDecodeError e_conv;
7866         e_conv.inner = (void*)(e & (~1));
7867         e_conv.is_owned = (e & 1) || (e == 0);
7868         e_conv = DecodeError_clone(&e_conv);
7869         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7870         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
7871         return (long)ret_conv;
7872 }
7873
7874 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
7875         if ((_res & 1) != 0) return;
7876         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7877         FREE((void*)_res);
7878         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
7879 }
7880
7881 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
7882         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
7883         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7884         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
7885         return (long)ret_conv;
7886 }
7887
7888 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
7889         LDKInit o_conv;
7890         o_conv.inner = (void*)(o & (~1));
7891         o_conv.is_owned = (o & 1) || (o == 0);
7892         o_conv = Init_clone(&o_conv);
7893         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7894         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
7895         return (long)ret_conv;
7896 }
7897
7898 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
7899         LDKDecodeError e_conv;
7900         e_conv.inner = (void*)(e & (~1));
7901         e_conv.is_owned = (e & 1) || (e == 0);
7902         e_conv = DecodeError_clone(&e_conv);
7903         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7904         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
7905         return (long)ret_conv;
7906 }
7907
7908 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
7909         if ((_res & 1) != 0) return;
7910         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
7911         FREE((void*)_res);
7912         CResult_InitDecodeErrorZ_free(_res_conv);
7913 }
7914
7915 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
7916         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
7917         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7918         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
7919         return (long)ret_conv;
7920 }
7921
7922 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
7923         LDKOpenChannel o_conv;
7924         o_conv.inner = (void*)(o & (~1));
7925         o_conv.is_owned = (o & 1) || (o == 0);
7926         o_conv = OpenChannel_clone(&o_conv);
7927         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7928         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
7929         return (long)ret_conv;
7930 }
7931
7932 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
7933         LDKDecodeError e_conv;
7934         e_conv.inner = (void*)(e & (~1));
7935         e_conv.is_owned = (e & 1) || (e == 0);
7936         e_conv = DecodeError_clone(&e_conv);
7937         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7938         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
7939         return (long)ret_conv;
7940 }
7941
7942 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
7943         if ((_res & 1) != 0) return;
7944         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7945         FREE((void*)_res);
7946         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
7947 }
7948
7949 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
7950         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
7951         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7952         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
7953         return (long)ret_conv;
7954 }
7955
7956 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
7957         LDKRevokeAndACK o_conv;
7958         o_conv.inner = (void*)(o & (~1));
7959         o_conv.is_owned = (o & 1) || (o == 0);
7960         o_conv = RevokeAndACK_clone(&o_conv);
7961         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7962         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
7963         return (long)ret_conv;
7964 }
7965
7966 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
7967         LDKDecodeError e_conv;
7968         e_conv.inner = (void*)(e & (~1));
7969         e_conv.is_owned = (e & 1) || (e == 0);
7970         e_conv = DecodeError_clone(&e_conv);
7971         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7972         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
7973         return (long)ret_conv;
7974 }
7975
7976 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
7977         if ((_res & 1) != 0) return;
7978         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
7979         FREE((void*)_res);
7980         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
7981 }
7982
7983 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
7984         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
7985         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
7986         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
7987         return (long)ret_conv;
7988 }
7989
7990 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
7991         LDKShutdown o_conv;
7992         o_conv.inner = (void*)(o & (~1));
7993         o_conv.is_owned = (o & 1) || (o == 0);
7994         o_conv = Shutdown_clone(&o_conv);
7995         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
7996         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
7997         return (long)ret_conv;
7998 }
7999
8000 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
8001         LDKDecodeError e_conv;
8002         e_conv.inner = (void*)(e & (~1));
8003         e_conv.is_owned = (e & 1) || (e == 0);
8004         e_conv = DecodeError_clone(&e_conv);
8005         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8006         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
8007         return (long)ret_conv;
8008 }
8009
8010 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
8011         if ((_res & 1) != 0) return;
8012         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
8013         FREE((void*)_res);
8014         CResult_ShutdownDecodeErrorZ_free(_res_conv);
8015 }
8016
8017 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
8018         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
8019         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8020         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
8021         return (long)ret_conv;
8022 }
8023
8024 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
8025         LDKUpdateFailHTLC o_conv;
8026         o_conv.inner = (void*)(o & (~1));
8027         o_conv.is_owned = (o & 1) || (o == 0);
8028         o_conv = UpdateFailHTLC_clone(&o_conv);
8029         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8030         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
8031         return (long)ret_conv;
8032 }
8033
8034 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
8035         LDKDecodeError e_conv;
8036         e_conv.inner = (void*)(e & (~1));
8037         e_conv.is_owned = (e & 1) || (e == 0);
8038         e_conv = DecodeError_clone(&e_conv);
8039         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8040         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
8041         return (long)ret_conv;
8042 }
8043
8044 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
8045         if ((_res & 1) != 0) return;
8046         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8047         FREE((void*)_res);
8048         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
8049 }
8050
8051 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
8052         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
8053         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8054         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
8055         return (long)ret_conv;
8056 }
8057
8058 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
8059         LDKUpdateFailMalformedHTLC o_conv;
8060         o_conv.inner = (void*)(o & (~1));
8061         o_conv.is_owned = (o & 1) || (o == 0);
8062         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
8063         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8064         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
8065         return (long)ret_conv;
8066 }
8067
8068 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_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_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8074         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
8075         return (long)ret_conv;
8076 }
8077
8078 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
8079         if ((_res & 1) != 0) return;
8080         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8081         FREE((void*)_res);
8082         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
8083 }
8084
8085 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
8086         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
8087         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8088         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
8089         return (long)ret_conv;
8090 }
8091
8092 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
8093         LDKUpdateFee o_conv;
8094         o_conv.inner = (void*)(o & (~1));
8095         o_conv.is_owned = (o & 1) || (o == 0);
8096         o_conv = UpdateFee_clone(&o_conv);
8097         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8098         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
8099         return (long)ret_conv;
8100 }
8101
8102 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
8103         LDKDecodeError e_conv;
8104         e_conv.inner = (void*)(e & (~1));
8105         e_conv.is_owned = (e & 1) || (e == 0);
8106         e_conv = DecodeError_clone(&e_conv);
8107         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8108         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
8109         return (long)ret_conv;
8110 }
8111
8112 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
8113         if ((_res & 1) != 0) return;
8114         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8115         FREE((void*)_res);
8116         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
8117 }
8118
8119 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
8120         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
8121         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8122         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
8123         return (long)ret_conv;
8124 }
8125
8126 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
8127         LDKUpdateFulfillHTLC o_conv;
8128         o_conv.inner = (void*)(o & (~1));
8129         o_conv.is_owned = (o & 1) || (o == 0);
8130         o_conv = UpdateFulfillHTLC_clone(&o_conv);
8131         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8132         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
8133         return (long)ret_conv;
8134 }
8135
8136 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
8137         LDKDecodeError e_conv;
8138         e_conv.inner = (void*)(e & (~1));
8139         e_conv.is_owned = (e & 1) || (e == 0);
8140         e_conv = DecodeError_clone(&e_conv);
8141         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8142         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
8143         return (long)ret_conv;
8144 }
8145
8146 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
8147         if ((_res & 1) != 0) return;
8148         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8149         FREE((void*)_res);
8150         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
8151 }
8152
8153 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
8154         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
8155         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8156         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
8157         return (long)ret_conv;
8158 }
8159
8160 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
8161         LDKUpdateAddHTLC o_conv;
8162         o_conv.inner = (void*)(o & (~1));
8163         o_conv.is_owned = (o & 1) || (o == 0);
8164         o_conv = UpdateAddHTLC_clone(&o_conv);
8165         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8166         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
8167         return (long)ret_conv;
8168 }
8169
8170 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
8171         LDKDecodeError e_conv;
8172         e_conv.inner = (void*)(e & (~1));
8173         e_conv.is_owned = (e & 1) || (e == 0);
8174         e_conv = DecodeError_clone(&e_conv);
8175         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8176         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
8177         return (long)ret_conv;
8178 }
8179
8180 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
8181         if ((_res & 1) != 0) return;
8182         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8183         FREE((void*)_res);
8184         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
8185 }
8186
8187 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
8188         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
8189         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8190         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
8191         return (long)ret_conv;
8192 }
8193
8194 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
8195         LDKPing o_conv;
8196         o_conv.inner = (void*)(o & (~1));
8197         o_conv.is_owned = (o & 1) || (o == 0);
8198         o_conv = Ping_clone(&o_conv);
8199         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8200         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
8201         return (long)ret_conv;
8202 }
8203
8204 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
8205         LDKDecodeError e_conv;
8206         e_conv.inner = (void*)(e & (~1));
8207         e_conv.is_owned = (e & 1) || (e == 0);
8208         e_conv = DecodeError_clone(&e_conv);
8209         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8210         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
8211         return (long)ret_conv;
8212 }
8213
8214 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
8215         if ((_res & 1) != 0) return;
8216         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
8217         FREE((void*)_res);
8218         CResult_PingDecodeErrorZ_free(_res_conv);
8219 }
8220
8221 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
8222         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
8223         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8224         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
8225         return (long)ret_conv;
8226 }
8227
8228 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
8229         LDKPong o_conv;
8230         o_conv.inner = (void*)(o & (~1));
8231         o_conv.is_owned = (o & 1) || (o == 0);
8232         o_conv = Pong_clone(&o_conv);
8233         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8234         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
8235         return (long)ret_conv;
8236 }
8237
8238 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
8239         LDKDecodeError e_conv;
8240         e_conv.inner = (void*)(e & (~1));
8241         e_conv.is_owned = (e & 1) || (e == 0);
8242         e_conv = DecodeError_clone(&e_conv);
8243         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8244         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
8245         return (long)ret_conv;
8246 }
8247
8248 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
8249         if ((_res & 1) != 0) return;
8250         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
8251         FREE((void*)_res);
8252         CResult_PongDecodeErrorZ_free(_res_conv);
8253 }
8254
8255 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
8256         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
8257         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8258         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
8259         return (long)ret_conv;
8260 }
8261
8262 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8263         LDKUnsignedChannelAnnouncement o_conv;
8264         o_conv.inner = (void*)(o & (~1));
8265         o_conv.is_owned = (o & 1) || (o == 0);
8266         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
8267         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8268         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
8269         return (long)ret_conv;
8270 }
8271
8272 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8273         LDKDecodeError e_conv;
8274         e_conv.inner = (void*)(e & (~1));
8275         e_conv.is_owned = (e & 1) || (e == 0);
8276         e_conv = DecodeError_clone(&e_conv);
8277         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8278         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
8279         return (long)ret_conv;
8280 }
8281
8282 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8283         if ((_res & 1) != 0) return;
8284         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8285         FREE((void*)_res);
8286         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
8287 }
8288
8289 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8290         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8291         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8292         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8293         return (long)ret_conv;
8294 }
8295
8296 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8297         LDKChannelAnnouncement o_conv;
8298         o_conv.inner = (void*)(o & (~1));
8299         o_conv.is_owned = (o & 1) || (o == 0);
8300         o_conv = ChannelAnnouncement_clone(&o_conv);
8301         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8302         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
8303         return (long)ret_conv;
8304 }
8305
8306 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8307         LDKDecodeError e_conv;
8308         e_conv.inner = (void*)(e & (~1));
8309         e_conv.is_owned = (e & 1) || (e == 0);
8310         e_conv = DecodeError_clone(&e_conv);
8311         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8312         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
8313         return (long)ret_conv;
8314 }
8315
8316 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8317         if ((_res & 1) != 0) return;
8318         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8319         FREE((void*)_res);
8320         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
8321 }
8322
8323 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8324         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8325         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8326         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8327         return (long)ret_conv;
8328 }
8329
8330 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8331         LDKUnsignedChannelUpdate o_conv;
8332         o_conv.inner = (void*)(o & (~1));
8333         o_conv.is_owned = (o & 1) || (o == 0);
8334         o_conv = UnsignedChannelUpdate_clone(&o_conv);
8335         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8336         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
8337         return (long)ret_conv;
8338 }
8339
8340 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
8341         LDKDecodeError e_conv;
8342         e_conv.inner = (void*)(e & (~1));
8343         e_conv.is_owned = (e & 1) || (e == 0);
8344         e_conv = DecodeError_clone(&e_conv);
8345         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8346         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
8347         return (long)ret_conv;
8348 }
8349
8350 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8351         if ((_res & 1) != 0) return;
8352         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8353         FREE((void*)_res);
8354         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
8355 }
8356
8357 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8358         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
8359         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8360         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
8361         return (long)ret_conv;
8362 }
8363
8364 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8365         LDKChannelUpdate o_conv;
8366         o_conv.inner = (void*)(o & (~1));
8367         o_conv.is_owned = (o & 1) || (o == 0);
8368         o_conv = ChannelUpdate_clone(&o_conv);
8369         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8370         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
8371         return (long)ret_conv;
8372 }
8373
8374 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
8375         LDKDecodeError e_conv;
8376         e_conv.inner = (void*)(e & (~1));
8377         e_conv.is_owned = (e & 1) || (e == 0);
8378         e_conv = DecodeError_clone(&e_conv);
8379         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8380         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
8381         return (long)ret_conv;
8382 }
8383
8384 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8385         if ((_res & 1) != 0) return;
8386         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8387         FREE((void*)_res);
8388         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
8389 }
8390
8391 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8392         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
8393         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8394         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
8395         return (long)ret_conv;
8396 }
8397
8398 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
8399         LDKErrorMessage o_conv;
8400         o_conv.inner = (void*)(o & (~1));
8401         o_conv.is_owned = (o & 1) || (o == 0);
8402         o_conv = ErrorMessage_clone(&o_conv);
8403         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8404         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
8405         return (long)ret_conv;
8406 }
8407
8408 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
8409         LDKDecodeError e_conv;
8410         e_conv.inner = (void*)(e & (~1));
8411         e_conv.is_owned = (e & 1) || (e == 0);
8412         e_conv = DecodeError_clone(&e_conv);
8413         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8414         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
8415         return (long)ret_conv;
8416 }
8417
8418 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
8419         if ((_res & 1) != 0) return;
8420         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
8421         FREE((void*)_res);
8422         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
8423 }
8424
8425 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
8426         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
8427         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8428         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
8429         return (long)ret_conv;
8430 }
8431
8432 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8433         LDKUnsignedNodeAnnouncement o_conv;
8434         o_conv.inner = (void*)(o & (~1));
8435         o_conv.is_owned = (o & 1) || (o == 0);
8436         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
8437         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8438         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
8439         return (long)ret_conv;
8440 }
8441
8442 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8443         LDKDecodeError e_conv;
8444         e_conv.inner = (void*)(e & (~1));
8445         e_conv.is_owned = (e & 1) || (e == 0);
8446         e_conv = DecodeError_clone(&e_conv);
8447         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8448         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
8449         return (long)ret_conv;
8450 }
8451
8452 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8453         if ((_res & 1) != 0) return;
8454         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8455         FREE((void*)_res);
8456         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
8457 }
8458
8459 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8460         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
8461         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8462         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
8463         return (long)ret_conv;
8464 }
8465
8466 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8467         LDKNodeAnnouncement o_conv;
8468         o_conv.inner = (void*)(o & (~1));
8469         o_conv.is_owned = (o & 1) || (o == 0);
8470         o_conv = NodeAnnouncement_clone(&o_conv);
8471         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8472         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
8473         return (long)ret_conv;
8474 }
8475
8476 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8477         LDKDecodeError e_conv;
8478         e_conv.inner = (void*)(e & (~1));
8479         e_conv.is_owned = (e & 1) || (e == 0);
8480         e_conv = DecodeError_clone(&e_conv);
8481         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8482         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
8483         return (long)ret_conv;
8484 }
8485
8486 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8487         if ((_res & 1) != 0) return;
8488         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8489         FREE((void*)_res);
8490         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
8491 }
8492
8493 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8494         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
8495         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8496         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
8497         return (long)ret_conv;
8498 }
8499
8500 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
8501         LDKQueryShortChannelIds o_conv;
8502         o_conv.inner = (void*)(o & (~1));
8503         o_conv.is_owned = (o & 1) || (o == 0);
8504         o_conv = QueryShortChannelIds_clone(&o_conv);
8505         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8506         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
8507         return (long)ret_conv;
8508 }
8509
8510 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
8511         LDKDecodeError e_conv;
8512         e_conv.inner = (void*)(e & (~1));
8513         e_conv.is_owned = (e & 1) || (e == 0);
8514         e_conv = DecodeError_clone(&e_conv);
8515         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8516         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
8517         return (long)ret_conv;
8518 }
8519
8520 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
8521         if ((_res & 1) != 0) return;
8522         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
8523         FREE((void*)_res);
8524         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
8525 }
8526
8527 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
8528         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
8529         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8530         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
8531         return (long)ret_conv;
8532 }
8533
8534 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
8535         LDKReplyShortChannelIdsEnd o_conv;
8536         o_conv.inner = (void*)(o & (~1));
8537         o_conv.is_owned = (o & 1) || (o == 0);
8538         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
8539         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8540         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
8541         return (long)ret_conv;
8542 }
8543
8544 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
8545         LDKDecodeError e_conv;
8546         e_conv.inner = (void*)(e & (~1));
8547         e_conv.is_owned = (e & 1) || (e == 0);
8548         e_conv = DecodeError_clone(&e_conv);
8549         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8550         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
8551         return (long)ret_conv;
8552 }
8553
8554 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
8555         if ((_res & 1) != 0) return;
8556         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
8557         FREE((void*)_res);
8558         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
8559 }
8560
8561 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
8562         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
8563         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8564         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
8565         return (long)ret_conv;
8566 }
8567
8568 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
8569         LDKQueryChannelRange o_conv;
8570         o_conv.inner = (void*)(o & (~1));
8571         o_conv.is_owned = (o & 1) || (o == 0);
8572         o_conv = QueryChannelRange_clone(&o_conv);
8573         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8574         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
8575         return (long)ret_conv;
8576 }
8577
8578 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
8579         LDKDecodeError e_conv;
8580         e_conv.inner = (void*)(e & (~1));
8581         e_conv.is_owned = (e & 1) || (e == 0);
8582         e_conv = DecodeError_clone(&e_conv);
8583         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8584         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
8585         return (long)ret_conv;
8586 }
8587
8588 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
8589         if ((_res & 1) != 0) return;
8590         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8591         FREE((void*)_res);
8592         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
8593 }
8594
8595 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8596         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
8597         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8598         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
8599         return (long)ret_conv;
8600 }
8601
8602 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
8603         LDKReplyChannelRange o_conv;
8604         o_conv.inner = (void*)(o & (~1));
8605         o_conv.is_owned = (o & 1) || (o == 0);
8606         o_conv = ReplyChannelRange_clone(&o_conv);
8607         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8608         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
8609         return (long)ret_conv;
8610 }
8611
8612 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
8613         LDKDecodeError e_conv;
8614         e_conv.inner = (void*)(e & (~1));
8615         e_conv.is_owned = (e & 1) || (e == 0);
8616         e_conv = DecodeError_clone(&e_conv);
8617         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8618         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
8619         return (long)ret_conv;
8620 }
8621
8622 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
8623         if ((_res & 1) != 0) return;
8624         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8625         FREE((void*)_res);
8626         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
8627 }
8628
8629 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8630         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
8631         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8632         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
8633         return (long)ret_conv;
8634 }
8635
8636 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
8637         LDKGossipTimestampFilter o_conv;
8638         o_conv.inner = (void*)(o & (~1));
8639         o_conv.is_owned = (o & 1) || (o == 0);
8640         o_conv = GossipTimestampFilter_clone(&o_conv);
8641         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8642         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
8643         return (long)ret_conv;
8644 }
8645
8646 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
8647         LDKDecodeError e_conv;
8648         e_conv.inner = (void*)(e & (~1));
8649         e_conv.is_owned = (e & 1) || (e == 0);
8650         e_conv = DecodeError_clone(&e_conv);
8651         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8652         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
8653         return (long)ret_conv;
8654 }
8655
8656 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
8657         if ((_res & 1) != 0) return;
8658         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
8659         FREE((void*)_res);
8660         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
8661 }
8662
8663 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
8664         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
8665         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8666         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
8667         return (long)ret_conv;
8668 }
8669
8670 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
8671         if ((this_ptr & 1) != 0) return;
8672         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
8673         FREE((void*)this_ptr);
8674         Event_free(this_ptr_conv);
8675 }
8676
8677 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
8678         LDKEvent* orig_conv = (LDKEvent*)orig;
8679         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
8680         *ret_copy = Event_clone(orig_conv);
8681         long ret_ref = (long)ret_copy;
8682         return ret_ref;
8683 }
8684
8685 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
8686         LDKEvent* obj_conv = (LDKEvent*)obj;
8687         LDKCVec_u8Z ret_var = Event_write(obj_conv);
8688         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8689         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
8690         CVec_u8Z_free(ret_var);
8691         return ret_arr;
8692 }
8693
8694 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
8695         if ((this_ptr & 1) != 0) return;
8696         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
8697         FREE((void*)this_ptr);
8698         MessageSendEvent_free(this_ptr_conv);
8699 }
8700
8701 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
8702         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
8703         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8704         *ret_copy = MessageSendEvent_clone(orig_conv);
8705         long ret_ref = (long)ret_copy;
8706         return ret_ref;
8707 }
8708
8709 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
8710         if ((this_ptr & 1) != 0) return;
8711         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
8712         FREE((void*)this_ptr);
8713         MessageSendEventsProvider_free(this_ptr_conv);
8714 }
8715
8716 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
8717         if ((this_ptr & 1) != 0) return;
8718         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
8719         FREE((void*)this_ptr);
8720         EventsProvider_free(this_ptr_conv);
8721 }
8722
8723 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
8724         if ((this_ptr & 1) != 0) return;
8725         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
8726         FREE((void*)this_ptr);
8727         APIError_free(this_ptr_conv);
8728 }
8729
8730 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
8731         LDKAPIError* orig_conv = (LDKAPIError*)orig;
8732         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
8733         *ret_copy = APIError_clone(orig_conv);
8734         long ret_ref = (long)ret_copy;
8735         return ret_ref;
8736 }
8737
8738 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
8739         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
8740         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
8741         return ret_conv;
8742 }
8743
8744 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
8745         uint32_t ret_conv = LDKLevel_to_js(Level_max());
8746         return ret_conv;
8747 }
8748
8749 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
8750         if ((this_ptr & 1) != 0) return;
8751         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
8752         FREE((void*)this_ptr);
8753         Logger_free(this_ptr_conv);
8754 }
8755
8756 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
8757         LDKChannelHandshakeConfig this_obj_conv;
8758         this_obj_conv.inner = (void*)(this_obj & (~1));
8759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
8760         ChannelHandshakeConfig_free(this_obj_conv);
8761 }
8762
8763 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
8764         LDKChannelHandshakeConfig this_ptr_conv;
8765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8766         this_ptr_conv.is_owned = false;
8767         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
8768         return ret_val;
8769 }
8770
8771 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
8772         LDKChannelHandshakeConfig this_ptr_conv;
8773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8774         this_ptr_conv.is_owned = false;
8775         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
8776 }
8777
8778 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
8779         LDKChannelHandshakeConfig this_ptr_conv;
8780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8781         this_ptr_conv.is_owned = false;
8782         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
8783         return ret_val;
8784 }
8785
8786 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
8787         LDKChannelHandshakeConfig this_ptr_conv;
8788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8789         this_ptr_conv.is_owned = false;
8790         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
8791 }
8792
8793 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
8794         LDKChannelHandshakeConfig this_ptr_conv;
8795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8796         this_ptr_conv.is_owned = false;
8797         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
8798         return ret_val;
8799 }
8800
8801 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8802         LDKChannelHandshakeConfig this_ptr_conv;
8803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8804         this_ptr_conv.is_owned = false;
8805         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
8806 }
8807
8808 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) {
8809         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
8810         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8811         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8812         long ret_ref = (long)ret_var.inner;
8813         if (ret_var.is_owned) {
8814                 ret_ref |= 1;
8815         }
8816         return ret_ref;
8817 }
8818
8819 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
8820         LDKChannelHandshakeConfig orig_conv;
8821         orig_conv.inner = (void*)(orig & (~1));
8822         orig_conv.is_owned = false;
8823         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
8824         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8825         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8826         long ret_ref = (long)ret_var.inner;
8827         if (ret_var.is_owned) {
8828                 ret_ref |= 1;
8829         }
8830         return ret_ref;
8831 }
8832
8833 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
8834         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
8835         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8836         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8837         long ret_ref = (long)ret_var.inner;
8838         if (ret_var.is_owned) {
8839                 ret_ref |= 1;
8840         }
8841         return ret_ref;
8842 }
8843
8844 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
8845         LDKChannelHandshakeLimits this_obj_conv;
8846         this_obj_conv.inner = (void*)(this_obj & (~1));
8847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
8848         ChannelHandshakeLimits_free(this_obj_conv);
8849 }
8850
8851 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
8852         LDKChannelHandshakeLimits this_ptr_conv;
8853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8854         this_ptr_conv.is_owned = false;
8855         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
8856         return ret_val;
8857 }
8858
8859 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
8860         LDKChannelHandshakeLimits this_ptr_conv;
8861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8862         this_ptr_conv.is_owned = false;
8863         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
8864 }
8865
8866 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
8867         LDKChannelHandshakeLimits this_ptr_conv;
8868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8869         this_ptr_conv.is_owned = false;
8870         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
8871         return ret_val;
8872 }
8873
8874 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8875         LDKChannelHandshakeLimits this_ptr_conv;
8876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8877         this_ptr_conv.is_owned = false;
8878         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
8879 }
8880
8881 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8882         LDKChannelHandshakeLimits this_ptr_conv;
8883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8884         this_ptr_conv.is_owned = false;
8885         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
8886         return ret_val;
8887 }
8888
8889 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8890         LDKChannelHandshakeLimits this_ptr_conv;
8891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8892         this_ptr_conv.is_owned = false;
8893         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8894 }
8895
8896 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
8897         LDKChannelHandshakeLimits this_ptr_conv;
8898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8899         this_ptr_conv.is_owned = false;
8900         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
8901         return ret_val;
8902 }
8903
8904 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8905         LDKChannelHandshakeLimits this_ptr_conv;
8906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8907         this_ptr_conv.is_owned = false;
8908         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
8909 }
8910
8911 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
8912         LDKChannelHandshakeLimits this_ptr_conv;
8913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8914         this_ptr_conv.is_owned = false;
8915         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
8916         return ret_val;
8917 }
8918
8919 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
8920         LDKChannelHandshakeLimits this_ptr_conv;
8921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8922         this_ptr_conv.is_owned = false;
8923         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
8924 }
8925
8926 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
8927         LDKChannelHandshakeLimits this_ptr_conv;
8928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8929         this_ptr_conv.is_owned = false;
8930         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
8931         return ret_val;
8932 }
8933
8934 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8935         LDKChannelHandshakeLimits this_ptr_conv;
8936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8937         this_ptr_conv.is_owned = false;
8938         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
8939 }
8940
8941 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
8942         LDKChannelHandshakeLimits this_ptr_conv;
8943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8944         this_ptr_conv.is_owned = false;
8945         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
8946         return ret_val;
8947 }
8948
8949 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8950         LDKChannelHandshakeLimits this_ptr_conv;
8951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8952         this_ptr_conv.is_owned = false;
8953         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
8954 }
8955
8956 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
8957         LDKChannelHandshakeLimits this_ptr_conv;
8958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8959         this_ptr_conv.is_owned = false;
8960         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
8961         return ret_val;
8962 }
8963
8964 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
8965         LDKChannelHandshakeLimits this_ptr_conv;
8966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8967         this_ptr_conv.is_owned = false;
8968         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
8969 }
8970
8971 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
8972         LDKChannelHandshakeLimits this_ptr_conv;
8973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8974         this_ptr_conv.is_owned = false;
8975         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
8976         return ret_val;
8977 }
8978
8979 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
8980         LDKChannelHandshakeLimits this_ptr_conv;
8981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8982         this_ptr_conv.is_owned = false;
8983         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
8984 }
8985
8986 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
8987         LDKChannelHandshakeLimits this_ptr_conv;
8988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8989         this_ptr_conv.is_owned = false;
8990         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
8991         return ret_val;
8992 }
8993
8994 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
8995         LDKChannelHandshakeLimits this_ptr_conv;
8996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8997         this_ptr_conv.is_owned = false;
8998         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
8999 }
9000
9001 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, int64_t min_dust_limit_satoshis_arg, int64_t max_dust_limit_satoshis_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
9002         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, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
9003         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9004         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9005         long ret_ref = (long)ret_var.inner;
9006         if (ret_var.is_owned) {
9007                 ret_ref |= 1;
9008         }
9009         return ret_ref;
9010 }
9011
9012 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
9013         LDKChannelHandshakeLimits orig_conv;
9014         orig_conv.inner = (void*)(orig & (~1));
9015         orig_conv.is_owned = false;
9016         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
9017         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9018         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9019         long ret_ref = (long)ret_var.inner;
9020         if (ret_var.is_owned) {
9021                 ret_ref |= 1;
9022         }
9023         return ret_ref;
9024 }
9025
9026 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
9027         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
9028         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9029         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9030         long ret_ref = (long)ret_var.inner;
9031         if (ret_var.is_owned) {
9032                 ret_ref |= 1;
9033         }
9034         return ret_ref;
9035 }
9036
9037 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
9038         LDKChannelConfig this_obj_conv;
9039         this_obj_conv.inner = (void*)(this_obj & (~1));
9040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9041         ChannelConfig_free(this_obj_conv);
9042 }
9043
9044 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
9045         LDKChannelConfig this_ptr_conv;
9046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9047         this_ptr_conv.is_owned = false;
9048         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
9049         return ret_val;
9050 }
9051
9052 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
9053         LDKChannelConfig this_ptr_conv;
9054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9055         this_ptr_conv.is_owned = false;
9056         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
9057 }
9058
9059 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
9060         LDKChannelConfig this_ptr_conv;
9061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9062         this_ptr_conv.is_owned = false;
9063         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
9064         return ret_val;
9065 }
9066
9067 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
9068         LDKChannelConfig this_ptr_conv;
9069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9070         this_ptr_conv.is_owned = false;
9071         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
9072 }
9073
9074 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
9075         LDKChannelConfig this_ptr_conv;
9076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9077         this_ptr_conv.is_owned = false;
9078         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
9079         return ret_val;
9080 }
9081
9082 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
9083         LDKChannelConfig this_ptr_conv;
9084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9085         this_ptr_conv.is_owned = false;
9086         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
9087 }
9088
9089 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
9090         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
9091         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9092         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9093         long ret_ref = (long)ret_var.inner;
9094         if (ret_var.is_owned) {
9095                 ret_ref |= 1;
9096         }
9097         return ret_ref;
9098 }
9099
9100 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
9101         LDKChannelConfig orig_conv;
9102         orig_conv.inner = (void*)(orig & (~1));
9103         orig_conv.is_owned = false;
9104         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
9105         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9106         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9107         long ret_ref = (long)ret_var.inner;
9108         if (ret_var.is_owned) {
9109                 ret_ref |= 1;
9110         }
9111         return ret_ref;
9112 }
9113
9114 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
9115         LDKChannelConfig ret_var = ChannelConfig_default();
9116         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9117         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9118         long ret_ref = (long)ret_var.inner;
9119         if (ret_var.is_owned) {
9120                 ret_ref |= 1;
9121         }
9122         return ret_ref;
9123 }
9124
9125 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
9126         LDKChannelConfig obj_conv;
9127         obj_conv.inner = (void*)(obj & (~1));
9128         obj_conv.is_owned = false;
9129         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
9130         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9131         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9132         CVec_u8Z_free(ret_var);
9133         return ret_arr;
9134 }
9135
9136 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
9137         LDKu8slice ser_ref;
9138         ser_ref.datalen = *((uint32_t*)ser);
9139         ser_ref.data = (int8_t*)(ser + 4);
9140         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9141         *ret_conv = ChannelConfig_read(ser_ref);
9142         return (long)ret_conv;
9143 }
9144
9145 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
9146         LDKUserConfig this_obj_conv;
9147         this_obj_conv.inner = (void*)(this_obj & (~1));
9148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9149         UserConfig_free(this_obj_conv);
9150 }
9151
9152 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
9153         LDKUserConfig this_ptr_conv;
9154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9155         this_ptr_conv.is_owned = false;
9156         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
9157         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9158         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9159         long ret_ref = (long)ret_var.inner;
9160         if (ret_var.is_owned) {
9161                 ret_ref |= 1;
9162         }
9163         return ret_ref;
9164 }
9165
9166 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
9167         LDKUserConfig this_ptr_conv;
9168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9169         this_ptr_conv.is_owned = false;
9170         LDKChannelHandshakeConfig val_conv;
9171         val_conv.inner = (void*)(val & (~1));
9172         val_conv.is_owned = (val & 1) || (val == 0);
9173         val_conv = ChannelHandshakeConfig_clone(&val_conv);
9174         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
9175 }
9176
9177 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
9178         LDKUserConfig this_ptr_conv;
9179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9180         this_ptr_conv.is_owned = false;
9181         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
9182         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9183         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9184         long ret_ref = (long)ret_var.inner;
9185         if (ret_var.is_owned) {
9186                 ret_ref |= 1;
9187         }
9188         return ret_ref;
9189 }
9190
9191 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
9192         LDKUserConfig this_ptr_conv;
9193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9194         this_ptr_conv.is_owned = false;
9195         LDKChannelHandshakeLimits val_conv;
9196         val_conv.inner = (void*)(val & (~1));
9197         val_conv.is_owned = (val & 1) || (val == 0);
9198         val_conv = ChannelHandshakeLimits_clone(&val_conv);
9199         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
9200 }
9201
9202 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
9203         LDKUserConfig this_ptr_conv;
9204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9205         this_ptr_conv.is_owned = false;
9206         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
9207         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9208         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9209         long ret_ref = (long)ret_var.inner;
9210         if (ret_var.is_owned) {
9211                 ret_ref |= 1;
9212         }
9213         return ret_ref;
9214 }
9215
9216 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
9217         LDKUserConfig this_ptr_conv;
9218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9219         this_ptr_conv.is_owned = false;
9220         LDKChannelConfig val_conv;
9221         val_conv.inner = (void*)(val & (~1));
9222         val_conv.is_owned = (val & 1) || (val == 0);
9223         val_conv = ChannelConfig_clone(&val_conv);
9224         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
9225 }
9226
9227 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) {
9228         LDKChannelHandshakeConfig own_channel_config_arg_conv;
9229         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
9230         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
9231         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
9232         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
9233         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
9234         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
9235         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
9236         LDKChannelConfig channel_options_arg_conv;
9237         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
9238         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
9239         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
9240         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
9241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9243         long ret_ref = (long)ret_var.inner;
9244         if (ret_var.is_owned) {
9245                 ret_ref |= 1;
9246         }
9247         return ret_ref;
9248 }
9249
9250 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
9251         LDKUserConfig orig_conv;
9252         orig_conv.inner = (void*)(orig & (~1));
9253         orig_conv.is_owned = false;
9254         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
9255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9257         long ret_ref = (long)ret_var.inner;
9258         if (ret_var.is_owned) {
9259                 ret_ref |= 1;
9260         }
9261         return ret_ref;
9262 }
9263
9264 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
9265         LDKUserConfig ret_var = UserConfig_default();
9266         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9267         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9268         long ret_ref = (long)ret_var.inner;
9269         if (ret_var.is_owned) {
9270                 ret_ref |= 1;
9271         }
9272         return ret_ref;
9273 }
9274
9275 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
9276         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
9277         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
9278         return ret_conv;
9279 }
9280
9281 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
9282         if ((this_ptr & 1) != 0) return;
9283         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
9284         FREE((void*)this_ptr);
9285         Access_free(this_ptr_conv);
9286 }
9287
9288 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
9289         if ((this_ptr & 1) != 0) return;
9290         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
9291         FREE((void*)this_ptr);
9292         Listen_free(this_ptr_conv);
9293 }
9294
9295 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
9296         if ((this_ptr & 1) != 0) return;
9297         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
9298         FREE((void*)this_ptr);
9299         Watch_free(this_ptr_conv);
9300 }
9301
9302 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
9303         if ((this_ptr & 1) != 0) return;
9304         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
9305         FREE((void*)this_ptr);
9306         Filter_free(this_ptr_conv);
9307 }
9308
9309 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
9310         if ((this_ptr & 1) != 0) return;
9311         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
9312         FREE((void*)this_ptr);
9313         BroadcasterInterface_free(this_ptr_conv);
9314 }
9315
9316 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
9317         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
9318         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
9319         return ret_conv;
9320 }
9321
9322 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
9323         if ((this_ptr & 1) != 0) return;
9324         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
9325         FREE((void*)this_ptr);
9326         FeeEstimator_free(this_ptr_conv);
9327 }
9328
9329 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
9330         LDKChainMonitor this_obj_conv;
9331         this_obj_conv.inner = (void*)(this_obj & (~1));
9332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9333         ChainMonitor_free(this_obj_conv);
9334 }
9335
9336 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9337         LDKChainMonitor this_arg_conv;
9338         this_arg_conv.inner = (void*)(this_arg & (~1));
9339         this_arg_conv.is_owned = false;
9340         unsigned char header_arr[80];
9341         CHECK(*((uint32_t*)header) == 80);
9342         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9343         unsigned char (*header_ref)[80] = &header_arr;
9344         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9345         txdata_constr.datalen = *((uint32_t*)txdata);
9346         if (txdata_constr.datalen > 0)
9347                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9348         else
9349                 txdata_constr.data = NULL;
9350         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9351         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9352                 uint32_t txdata_conv_30 = txdata_vals[e];
9353                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9354                 FREE((void*)txdata_conv_30);
9355                 txdata_constr.data[e] = txdata_conv_30_conv;
9356         }
9357         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
9358 }
9359
9360 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
9361         LDKChainMonitor this_arg_conv;
9362         this_arg_conv.inner = (void*)(this_arg & (~1));
9363         this_arg_conv.is_owned = false;
9364         unsigned char header_arr[80];
9365         CHECK(*((uint32_t*)header) == 80);
9366         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9367         unsigned char (*header_ref)[80] = &header_arr;
9368         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
9369 }
9370
9371 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
9372         LDKFilter *chain_source_conv_ptr = NULL;
9373         if (chain_source != 0) {
9374                 LDKFilter chain_source_conv;
9375                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
9376                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9377                 *chain_source_conv_ptr = chain_source_conv;
9378         }
9379         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9380         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9381         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
9382         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
9383         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
9384         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9385         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9386         long ret_ref = (long)ret_var.inner;
9387         if (ret_var.is_owned) {
9388                 ret_ref |= 1;
9389         }
9390         return ret_ref;
9391 }
9392
9393 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
9394         LDKChainMonitor this_arg_conv;
9395         this_arg_conv.inner = (void*)(this_arg & (~1));
9396         this_arg_conv.is_owned = false;
9397         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
9398         *ret = ChainMonitor_as_Watch(&this_arg_conv);
9399         return (long)ret;
9400 }
9401
9402 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
9403         LDKChainMonitor this_arg_conv;
9404         this_arg_conv.inner = (void*)(this_arg & (~1));
9405         this_arg_conv.is_owned = false;
9406         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9407         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
9408         return (long)ret;
9409 }
9410
9411 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
9412         LDKChannelMonitorUpdate this_obj_conv;
9413         this_obj_conv.inner = (void*)(this_obj & (~1));
9414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9415         ChannelMonitorUpdate_free(this_obj_conv);
9416 }
9417
9418 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
9419         LDKChannelMonitorUpdate this_ptr_conv;
9420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9421         this_ptr_conv.is_owned = false;
9422         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
9423         return ret_val;
9424 }
9425
9426 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
9427         LDKChannelMonitorUpdate this_ptr_conv;
9428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9429         this_ptr_conv.is_owned = false;
9430         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
9431 }
9432
9433 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
9434         LDKChannelMonitorUpdate orig_conv;
9435         orig_conv.inner = (void*)(orig & (~1));
9436         orig_conv.is_owned = false;
9437         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
9438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9440         long ret_ref = (long)ret_var.inner;
9441         if (ret_var.is_owned) {
9442                 ret_ref |= 1;
9443         }
9444         return ret_ref;
9445 }
9446
9447 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
9448         LDKChannelMonitorUpdate obj_conv;
9449         obj_conv.inner = (void*)(obj & (~1));
9450         obj_conv.is_owned = false;
9451         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
9452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9454         CVec_u8Z_free(ret_var);
9455         return ret_arr;
9456 }
9457
9458 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
9459         LDKu8slice ser_ref;
9460         ser_ref.datalen = *((uint32_t*)ser);
9461         ser_ref.data = (int8_t*)(ser + 4);
9462         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9463         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
9464         return (long)ret_conv;
9465 }
9466
9467 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
9468         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
9469         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
9470         return ret_conv;
9471 }
9472
9473 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
9474         LDKMonitorUpdateError this_obj_conv;
9475         this_obj_conv.inner = (void*)(this_obj & (~1));
9476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9477         MonitorUpdateError_free(this_obj_conv);
9478 }
9479
9480 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
9481         LDKMonitorUpdateError orig_conv;
9482         orig_conv.inner = (void*)(orig & (~1));
9483         orig_conv.is_owned = false;
9484         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
9485         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9486         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9487         long ret_ref = (long)ret_var.inner;
9488         if (ret_var.is_owned) {
9489                 ret_ref |= 1;
9490         }
9491         return ret_ref;
9492 }
9493
9494 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
9495         if ((this_ptr & 1) != 0) return;
9496         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
9497         FREE((void*)this_ptr);
9498         MonitorEvent_free(this_ptr_conv);
9499 }
9500
9501 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
9502         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
9503         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
9504         *ret_copy = MonitorEvent_clone(orig_conv);
9505         long ret_ref = (long)ret_copy;
9506         return ret_ref;
9507 }
9508
9509 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
9510         LDKHTLCUpdate this_obj_conv;
9511         this_obj_conv.inner = (void*)(this_obj & (~1));
9512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9513         HTLCUpdate_free(this_obj_conv);
9514 }
9515
9516 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
9517         LDKHTLCUpdate orig_conv;
9518         orig_conv.inner = (void*)(orig & (~1));
9519         orig_conv.is_owned = false;
9520         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
9521         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9522         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9523         long ret_ref = (long)ret_var.inner;
9524         if (ret_var.is_owned) {
9525                 ret_ref |= 1;
9526         }
9527         return ret_ref;
9528 }
9529
9530 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
9531         LDKHTLCUpdate obj_conv;
9532         obj_conv.inner = (void*)(obj & (~1));
9533         obj_conv.is_owned = false;
9534         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
9535         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9536         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9537         CVec_u8Z_free(ret_var);
9538         return ret_arr;
9539 }
9540
9541 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
9542         LDKu8slice ser_ref;
9543         ser_ref.datalen = *((uint32_t*)ser);
9544         ser_ref.data = (int8_t*)(ser + 4);
9545         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9546         *ret_conv = HTLCUpdate_read(ser_ref);
9547         return (long)ret_conv;
9548 }
9549
9550 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
9551         LDKChannelMonitor this_obj_conv;
9552         this_obj_conv.inner = (void*)(this_obj & (~1));
9553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9554         ChannelMonitor_free(this_obj_conv);
9555 }
9556
9557 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
9558         LDKChannelMonitor orig_conv;
9559         orig_conv.inner = (void*)(orig & (~1));
9560         orig_conv.is_owned = false;
9561         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
9562         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9563         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9564         long ret_ref = (long)ret_var.inner;
9565         if (ret_var.is_owned) {
9566                 ret_ref |= 1;
9567         }
9568         return ret_ref;
9569 }
9570
9571 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
9572         LDKChannelMonitor obj_conv;
9573         obj_conv.inner = (void*)(obj & (~1));
9574         obj_conv.is_owned = false;
9575         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
9576         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9577         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9578         CVec_u8Z_free(ret_var);
9579         return ret_arr;
9580 }
9581
9582 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) {
9583         LDKChannelMonitor this_arg_conv;
9584         this_arg_conv.inner = (void*)(this_arg & (~1));
9585         this_arg_conv.is_owned = false;
9586         LDKChannelMonitorUpdate updates_conv;
9587         updates_conv.inner = (void*)(updates & (~1));
9588         updates_conv.is_owned = false;
9589         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9590         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9591         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
9592         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9593         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
9594         return (long)ret_conv;
9595 }
9596
9597 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
9598         LDKChannelMonitor this_arg_conv;
9599         this_arg_conv.inner = (void*)(this_arg & (~1));
9600         this_arg_conv.is_owned = false;
9601         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
9602         return ret_val;
9603 }
9604
9605 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
9606         LDKChannelMonitor this_arg_conv;
9607         this_arg_conv.inner = (void*)(this_arg & (~1));
9608         this_arg_conv.is_owned = false;
9609         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9610         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
9611         return (long)ret_ref;
9612 }
9613
9614 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
9615         LDKChannelMonitor this_arg_conv;
9616         this_arg_conv.inner = (void*)(this_arg & (~1));
9617         this_arg_conv.is_owned = false;
9618         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
9619         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9620         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9621         for (size_t c = 0; c < ret_var.datalen; c++) {
9622                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9623                 *ret_conv_54_ref = ret_var.data[c];
9624                 ret_arr_ptr[c] = (long)ret_conv_54_ref;
9625         }
9626         FREE(ret_var.data);
9627         return ret_arr;
9628 }
9629
9630 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
9631         LDKChannelMonitor this_arg_conv;
9632         this_arg_conv.inner = (void*)(this_arg & (~1));
9633         this_arg_conv.is_owned = false;
9634         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
9635         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
9636 }
9637
9638 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
9639         LDKChannelMonitor this_arg_conv;
9640         this_arg_conv.inner = (void*)(this_arg & (~1));
9641         this_arg_conv.is_owned = false;
9642         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
9643         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9644         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9645         for (size_t o = 0; o < ret_var.datalen; o++) {
9646                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
9647                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
9648                 long ret_conv_14_ref = (long)ret_conv_14_copy;
9649                 ret_arr_ptr[o] = ret_conv_14_ref;
9650         }
9651         FREE(ret_var.data);
9652         return ret_arr;
9653 }
9654
9655 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
9656         LDKChannelMonitor this_arg_conv;
9657         this_arg_conv.inner = (void*)(this_arg & (~1));
9658         this_arg_conv.is_owned = false;
9659         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
9660         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9661         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9662         for (size_t h = 0; h < ret_var.datalen; h++) {
9663                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9664                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
9665                 long ret_conv_7_ref = (long)ret_conv_7_copy;
9666                 ret_arr_ptr[h] = ret_conv_7_ref;
9667         }
9668         FREE(ret_var.data);
9669         return ret_arr;
9670 }
9671
9672 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
9673         LDKChannelMonitor this_arg_conv;
9674         this_arg_conv.inner = (void*)(this_arg & (~1));
9675         this_arg_conv.is_owned = false;
9676         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
9677         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
9678         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
9679         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
9680         for (size_t m = 0; m < ret_var.datalen; m++) {
9681                 LDKTransaction ret_conv_12_var = ret_var.data[m];
9682                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9683                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
9684                 Transaction_free(ret_conv_12_var);
9685                 ret_arr_ptr[m] = ret_conv_12_arr;
9686         }
9687         FREE(ret_var.data);
9688         return ret_arr;
9689 }
9690
9691 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) {
9692         LDKChannelMonitor this_arg_conv;
9693         this_arg_conv.inner = (void*)(this_arg & (~1));
9694         this_arg_conv.is_owned = false;
9695         unsigned char header_arr[80];
9696         CHECK(*((uint32_t*)header) == 80);
9697         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9698         unsigned char (*header_ref)[80] = &header_arr;
9699         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9700         txdata_constr.datalen = *((uint32_t*)txdata);
9701         if (txdata_constr.datalen > 0)
9702                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9703         else
9704                 txdata_constr.data = NULL;
9705         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9706         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9707                 uint32_t txdata_conv_30 = txdata_vals[e];
9708                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9709                 FREE((void*)txdata_conv_30);
9710                 txdata_constr.data[e] = txdata_conv_30_conv;
9711         }
9712         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9713         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9714         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9715         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);
9716         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9717         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9718         for (size_t x = 0; x < ret_var.datalen; x++) {
9719                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9720                 *ret_conv_49_ref = ret_var.data[x];
9721                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
9722         }
9723         FREE(ret_var.data);
9724         return ret_arr;
9725 }
9726
9727 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) {
9728         LDKChannelMonitor this_arg_conv;
9729         this_arg_conv.inner = (void*)(this_arg & (~1));
9730         this_arg_conv.is_owned = false;
9731         unsigned char header_arr[80];
9732         CHECK(*((uint32_t*)header) == 80);
9733         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9734         unsigned char (*header_ref)[80] = &header_arr;
9735         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9736         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9737         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9738         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
9739 }
9740
9741 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
9742         if ((this_ptr & 1) != 0) return;
9743         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
9744         FREE((void*)this_ptr);
9745         Persist_free(this_ptr_conv);
9746 }
9747
9748 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
9749         LDKu8slice ser_ref;
9750         ser_ref.datalen = *((uint32_t*)ser);
9751         ser_ref.data = (int8_t*)(ser + 4);
9752         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
9753         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9754         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
9755         return (long)ret_conv;
9756 }
9757
9758 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
9759         LDKOutPoint this_obj_conv;
9760         this_obj_conv.inner = (void*)(this_obj & (~1));
9761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9762         OutPoint_free(this_obj_conv);
9763 }
9764
9765 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
9766         LDKOutPoint this_ptr_conv;
9767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9768         this_ptr_conv.is_owned = false;
9769         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9770         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
9771         return ret_arr;
9772 }
9773
9774 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
9775         LDKOutPoint this_ptr_conv;
9776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9777         this_ptr_conv.is_owned = false;
9778         LDKThirtyTwoBytes val_ref;
9779         CHECK(*((uint32_t*)val) == 32);
9780         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9781         OutPoint_set_txid(&this_ptr_conv, val_ref);
9782 }
9783
9784 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
9785         LDKOutPoint this_ptr_conv;
9786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9787         this_ptr_conv.is_owned = false;
9788         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
9789         return ret_val;
9790 }
9791
9792 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
9793         LDKOutPoint this_ptr_conv;
9794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9795         this_ptr_conv.is_owned = false;
9796         OutPoint_set_index(&this_ptr_conv, val);
9797 }
9798
9799 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
9800         LDKThirtyTwoBytes txid_arg_ref;
9801         CHECK(*((uint32_t*)txid_arg) == 32);
9802         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
9803         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
9804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9806         long ret_ref = (long)ret_var.inner;
9807         if (ret_var.is_owned) {
9808                 ret_ref |= 1;
9809         }
9810         return ret_ref;
9811 }
9812
9813 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
9814         LDKOutPoint orig_conv;
9815         orig_conv.inner = (void*)(orig & (~1));
9816         orig_conv.is_owned = false;
9817         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
9818         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9819         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9820         long ret_ref = (long)ret_var.inner;
9821         if (ret_var.is_owned) {
9822                 ret_ref |= 1;
9823         }
9824         return ret_ref;
9825 }
9826
9827 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
9828         LDKOutPoint this_arg_conv;
9829         this_arg_conv.inner = (void*)(this_arg & (~1));
9830         this_arg_conv.is_owned = false;
9831         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9832         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
9833         return ret_arr;
9834 }
9835
9836 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
9837         LDKOutPoint obj_conv;
9838         obj_conv.inner = (void*)(obj & (~1));
9839         obj_conv.is_owned = false;
9840         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
9841         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9842         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9843         CVec_u8Z_free(ret_var);
9844         return ret_arr;
9845 }
9846
9847 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
9848         LDKu8slice ser_ref;
9849         ser_ref.datalen = *((uint32_t*)ser);
9850         ser_ref.data = (int8_t*)(ser + 4);
9851         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9852         *ret_conv = OutPoint_read(ser_ref);
9853         return (long)ret_conv;
9854 }
9855
9856 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
9857         LDKDelayedPaymentOutputDescriptor this_obj_conv;
9858         this_obj_conv.inner = (void*)(this_obj & (~1));
9859         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9860         DelayedPaymentOutputDescriptor_free(this_obj_conv);
9861 }
9862
9863 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
9864         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9866         this_ptr_conv.is_owned = false;
9867         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
9868         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9869         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9870         long ret_ref = (long)ret_var.inner;
9871         if (ret_var.is_owned) {
9872                 ret_ref |= 1;
9873         }
9874         return ret_ref;
9875 }
9876
9877 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
9878         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9880         this_ptr_conv.is_owned = false;
9881         LDKOutPoint val_conv;
9882         val_conv.inner = (void*)(val & (~1));
9883         val_conv.is_owned = (val & 1) || (val == 0);
9884         val_conv = OutPoint_clone(&val_conv);
9885         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
9886 }
9887
9888 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
9889         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9891         this_ptr_conv.is_owned = false;
9892         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9893         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9894         return ret_arr;
9895 }
9896
9897 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9898         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9900         this_ptr_conv.is_owned = false;
9901         LDKPublicKey val_ref;
9902         CHECK(*((uint32_t*)val) == 33);
9903         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9904         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
9905 }
9906
9907 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
9908         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9910         this_ptr_conv.is_owned = false;
9911         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
9912         return ret_val;
9913 }
9914
9915 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
9916         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9918         this_ptr_conv.is_owned = false;
9919         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
9920 }
9921
9922 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
9923         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9925         this_ptr_conv.is_owned = false;
9926         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
9927         FREE((void*)val);
9928         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
9929 }
9930
9931 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
9932         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9934         this_ptr_conv.is_owned = false;
9935         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9936         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
9937         return ret_arr;
9938 }
9939
9940 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
9941         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9943         this_ptr_conv.is_owned = false;
9944         LDKPublicKey val_ref;
9945         CHECK(*((uint32_t*)val) == 33);
9946         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9947         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
9948 }
9949
9950 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
9951         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9953         this_ptr_conv.is_owned = false;
9954         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9955         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
9956         return ret_arr;
9957 }
9958
9959 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
9960         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9962         this_ptr_conv.is_owned = false;
9963         LDKThirtyTwoBytes val_ref;
9964         CHECK(*((uint32_t*)val) == 32);
9965         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9966         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
9967 }
9968
9969 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
9970         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9972         this_ptr_conv.is_owned = false;
9973         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
9974         return ret_val;
9975 }
9976
9977 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
9978         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9980         this_ptr_conv.is_owned = false;
9981         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
9982 }
9983
9984 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) {
9985         LDKOutPoint outpoint_arg_conv;
9986         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
9987         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
9988         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
9989         LDKPublicKey per_commitment_point_arg_ref;
9990         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
9991         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
9992         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
9993         FREE((void*)output_arg);
9994         LDKPublicKey revocation_pubkey_arg_ref;
9995         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
9996         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
9997         LDKThirtyTwoBytes channel_keys_id_arg_ref;
9998         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
9999         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10000         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);
10001         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10002         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10003         long ret_ref = (long)ret_var.inner;
10004         if (ret_var.is_owned) {
10005                 ret_ref |= 1;
10006         }
10007         return ret_ref;
10008 }
10009
10010 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
10011         LDKDelayedPaymentOutputDescriptor orig_conv;
10012         orig_conv.inner = (void*)(orig & (~1));
10013         orig_conv.is_owned = false;
10014         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
10015         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10016         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10017         long ret_ref = (long)ret_var.inner;
10018         if (ret_var.is_owned) {
10019                 ret_ref |= 1;
10020         }
10021         return ret_ref;
10022 }
10023
10024 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
10025         LDKStaticPaymentOutputDescriptor this_obj_conv;
10026         this_obj_conv.inner = (void*)(this_obj & (~1));
10027         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10028         StaticPaymentOutputDescriptor_free(this_obj_conv);
10029 }
10030
10031 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10032         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10034         this_ptr_conv.is_owned = false;
10035         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10036         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10037         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10038         long ret_ref = (long)ret_var.inner;
10039         if (ret_var.is_owned) {
10040                 ret_ref |= 1;
10041         }
10042         return ret_ref;
10043 }
10044
10045 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10046         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10048         this_ptr_conv.is_owned = false;
10049         LDKOutPoint val_conv;
10050         val_conv.inner = (void*)(val & (~1));
10051         val_conv.is_owned = (val & 1) || (val == 0);
10052         val_conv = OutPoint_clone(&val_conv);
10053         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10054 }
10055
10056 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10057         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10059         this_ptr_conv.is_owned = false;
10060         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10061         FREE((void*)val);
10062         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10063 }
10064
10065 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10066         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10068         this_ptr_conv.is_owned = false;
10069         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10070         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10071         return ret_arr;
10072 }
10073
10074 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10075         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10077         this_ptr_conv.is_owned = false;
10078         LDKThirtyTwoBytes val_ref;
10079         CHECK(*((uint32_t*)val) == 32);
10080         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10081         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10082 }
10083
10084 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10085         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10087         this_ptr_conv.is_owned = false;
10088         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10089         return ret_val;
10090 }
10091
10092 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10093         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10095         this_ptr_conv.is_owned = false;
10096         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10097 }
10098
10099 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) {
10100         LDKOutPoint outpoint_arg_conv;
10101         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10102         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10103         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10104         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10105         FREE((void*)output_arg);
10106         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10107         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10108         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10109         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
10110         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10111         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10112         long ret_ref = (long)ret_var.inner;
10113         if (ret_var.is_owned) {
10114                 ret_ref |= 1;
10115         }
10116         return ret_ref;
10117 }
10118
10119 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
10120         LDKStaticPaymentOutputDescriptor orig_conv;
10121         orig_conv.inner = (void*)(orig & (~1));
10122         orig_conv.is_owned = false;
10123         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
10124         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10125         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10126         long ret_ref = (long)ret_var.inner;
10127         if (ret_var.is_owned) {
10128                 ret_ref |= 1;
10129         }
10130         return ret_ref;
10131 }
10132
10133 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
10134         if ((this_ptr & 1) != 0) return;
10135         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
10136         FREE((void*)this_ptr);
10137         SpendableOutputDescriptor_free(this_ptr_conv);
10138 }
10139
10140 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
10141         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
10142         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
10143         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
10144         long ret_ref = (long)ret_copy;
10145         return ret_ref;
10146 }
10147
10148 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
10149         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
10150         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
10151         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10152         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10153         CVec_u8Z_free(ret_var);
10154         return ret_arr;
10155 }
10156
10157 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
10158         LDKu8slice ser_ref;
10159         ser_ref.datalen = *((uint32_t*)ser);
10160         ser_ref.data = (int8_t*)(ser + 4);
10161         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10162         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
10163         return (long)ret_conv;
10164 }
10165
10166 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
10167         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
10168         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10169         *ret = Sign_clone(orig_conv);
10170         return (long)ret;
10171 }
10172
10173 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
10174         if ((this_ptr & 1) != 0) return;
10175         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
10176         FREE((void*)this_ptr);
10177         Sign_free(this_ptr_conv);
10178 }
10179
10180 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
10181         if ((this_ptr & 1) != 0) return;
10182         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
10183         FREE((void*)this_ptr);
10184         KeysInterface_free(this_ptr_conv);
10185 }
10186
10187 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
10188         LDKInMemorySigner this_obj_conv;
10189         this_obj_conv.inner = (void*)(this_obj & (~1));
10190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10191         InMemorySigner_free(this_obj_conv);
10192 }
10193
10194 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
10195         LDKInMemorySigner this_ptr_conv;
10196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10197         this_ptr_conv.is_owned = false;
10198         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10199         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
10200         return ret_arr;
10201 }
10202
10203 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
10204         LDKInMemorySigner this_ptr_conv;
10205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10206         this_ptr_conv.is_owned = false;
10207         LDKSecretKey val_ref;
10208         CHECK(*((uint32_t*)val) == 32);
10209         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10210         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
10211 }
10212
10213 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
10214         LDKInMemorySigner this_ptr_conv;
10215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10216         this_ptr_conv.is_owned = false;
10217         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10218         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
10219         return ret_arr;
10220 }
10221
10222 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
10223         LDKInMemorySigner this_ptr_conv;
10224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10225         this_ptr_conv.is_owned = false;
10226         LDKSecretKey val_ref;
10227         CHECK(*((uint32_t*)val) == 32);
10228         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10229         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
10230 }
10231
10232 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
10233         LDKInMemorySigner this_ptr_conv;
10234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10235         this_ptr_conv.is_owned = false;
10236         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10237         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
10238         return ret_arr;
10239 }
10240
10241 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
10242         LDKInMemorySigner this_ptr_conv;
10243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10244         this_ptr_conv.is_owned = false;
10245         LDKSecretKey val_ref;
10246         CHECK(*((uint32_t*)val) == 32);
10247         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10248         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
10249 }
10250
10251 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
10252         LDKInMemorySigner this_ptr_conv;
10253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10254         this_ptr_conv.is_owned = false;
10255         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10256         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
10257         return ret_arr;
10258 }
10259
10260 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
10261         LDKInMemorySigner this_ptr_conv;
10262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10263         this_ptr_conv.is_owned = false;
10264         LDKSecretKey val_ref;
10265         CHECK(*((uint32_t*)val) == 32);
10266         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10267         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
10268 }
10269
10270 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
10271         LDKInMemorySigner this_ptr_conv;
10272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10273         this_ptr_conv.is_owned = false;
10274         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10275         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
10276         return ret_arr;
10277 }
10278
10279 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
10280         LDKInMemorySigner this_ptr_conv;
10281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10282         this_ptr_conv.is_owned = false;
10283         LDKSecretKey val_ref;
10284         CHECK(*((uint32_t*)val) == 32);
10285         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10286         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
10287 }
10288
10289 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
10290         LDKInMemorySigner this_ptr_conv;
10291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10292         this_ptr_conv.is_owned = false;
10293         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10294         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
10295         return ret_arr;
10296 }
10297
10298 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
10299         LDKInMemorySigner this_ptr_conv;
10300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10301         this_ptr_conv.is_owned = false;
10302         LDKThirtyTwoBytes val_ref;
10303         CHECK(*((uint32_t*)val) == 32);
10304         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10305         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
10306 }
10307
10308 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
10309         LDKInMemorySigner orig_conv;
10310         orig_conv.inner = (void*)(orig & (~1));
10311         orig_conv.is_owned = false;
10312         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
10313         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10314         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10315         long ret_ref = (long)ret_var.inner;
10316         if (ret_var.is_owned) {
10317                 ret_ref |= 1;
10318         }
10319         return ret_ref;
10320 }
10321
10322 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) {
10323         LDKSecretKey funding_key_ref;
10324         CHECK(*((uint32_t*)funding_key) == 32);
10325         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
10326         LDKSecretKey revocation_base_key_ref;
10327         CHECK(*((uint32_t*)revocation_base_key) == 32);
10328         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
10329         LDKSecretKey payment_key_ref;
10330         CHECK(*((uint32_t*)payment_key) == 32);
10331         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
10332         LDKSecretKey delayed_payment_base_key_ref;
10333         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
10334         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
10335         LDKSecretKey htlc_base_key_ref;
10336         CHECK(*((uint32_t*)htlc_base_key) == 32);
10337         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
10338         LDKThirtyTwoBytes commitment_seed_ref;
10339         CHECK(*((uint32_t*)commitment_seed) == 32);
10340         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
10341         LDKThirtyTwoBytes channel_keys_id_ref;
10342         CHECK(*((uint32_t*)channel_keys_id) == 32);
10343         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
10344         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);
10345         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10346         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10347         long ret_ref = (long)ret_var.inner;
10348         if (ret_var.is_owned) {
10349                 ret_ref |= 1;
10350         }
10351         return ret_ref;
10352 }
10353
10354 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
10355         LDKInMemorySigner this_arg_conv;
10356         this_arg_conv.inner = (void*)(this_arg & (~1));
10357         this_arg_conv.is_owned = false;
10358         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
10359         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10360         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10361         long ret_ref = (long)ret_var.inner;
10362         if (ret_var.is_owned) {
10363                 ret_ref |= 1;
10364         }
10365         return ret_ref;
10366 }
10367
10368 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
10369         LDKInMemorySigner this_arg_conv;
10370         this_arg_conv.inner = (void*)(this_arg & (~1));
10371         this_arg_conv.is_owned = false;
10372         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
10373         return ret_val;
10374 }
10375
10376 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
10377         LDKInMemorySigner this_arg_conv;
10378         this_arg_conv.inner = (void*)(this_arg & (~1));
10379         this_arg_conv.is_owned = false;
10380         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
10381         return ret_val;
10382 }
10383
10384 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
10385         LDKInMemorySigner this_arg_conv;
10386         this_arg_conv.inner = (void*)(this_arg & (~1));
10387         this_arg_conv.is_owned = false;
10388         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
10389         return ret_val;
10390 }
10391
10392 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
10393         LDKInMemorySigner this_arg_conv;
10394         this_arg_conv.inner = (void*)(this_arg & (~1));
10395         this_arg_conv.is_owned = false;
10396         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
10397         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10398         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10399         long ret_ref = (long)ret_var.inner;
10400         if (ret_var.is_owned) {
10401                 ret_ref |= 1;
10402         }
10403         return ret_ref;
10404 }
10405
10406 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
10407         LDKInMemorySigner this_arg_conv;
10408         this_arg_conv.inner = (void*)(this_arg & (~1));
10409         this_arg_conv.is_owned = false;
10410         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
10411         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10412         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10413         long ret_ref = (long)ret_var.inner;
10414         if (ret_var.is_owned) {
10415                 ret_ref |= 1;
10416         }
10417         return ret_ref;
10418 }
10419
10420 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) {
10421         LDKInMemorySigner this_arg_conv;
10422         this_arg_conv.inner = (void*)(this_arg & (~1));
10423         this_arg_conv.is_owned = false;
10424         LDKTransaction spend_tx_ref;
10425         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10426         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10427         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10428         spend_tx_ref.data_is_owned = true;
10429         LDKStaticPaymentOutputDescriptor descriptor_conv;
10430         descriptor_conv.inner = (void*)(descriptor & (~1));
10431         descriptor_conv.is_owned = false;
10432         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10433         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10434         return (long)ret_conv;
10435 }
10436
10437 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) {
10438         LDKInMemorySigner this_arg_conv;
10439         this_arg_conv.inner = (void*)(this_arg & (~1));
10440         this_arg_conv.is_owned = false;
10441         LDKTransaction spend_tx_ref;
10442         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10443         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10444         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10445         spend_tx_ref.data_is_owned = true;
10446         LDKDelayedPaymentOutputDescriptor descriptor_conv;
10447         descriptor_conv.inner = (void*)(descriptor & (~1));
10448         descriptor_conv.is_owned = false;
10449         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10450         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10451         return (long)ret_conv;
10452 }
10453
10454 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
10455         LDKInMemorySigner this_arg_conv;
10456         this_arg_conv.inner = (void*)(this_arg & (~1));
10457         this_arg_conv.is_owned = false;
10458         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10459         *ret = InMemorySigner_as_Sign(&this_arg_conv);
10460         return (long)ret;
10461 }
10462
10463 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
10464         LDKInMemorySigner obj_conv;
10465         obj_conv.inner = (void*)(obj & (~1));
10466         obj_conv.is_owned = false;
10467         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
10468         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10469         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10470         CVec_u8Z_free(ret_var);
10471         return ret_arr;
10472 }
10473
10474 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
10475         LDKu8slice ser_ref;
10476         ser_ref.datalen = *((uint32_t*)ser);
10477         ser_ref.data = (int8_t*)(ser + 4);
10478         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10479         *ret_conv = InMemorySigner_read(ser_ref);
10480         return (long)ret_conv;
10481 }
10482
10483 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
10484         LDKKeysManager this_obj_conv;
10485         this_obj_conv.inner = (void*)(this_obj & (~1));
10486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10487         KeysManager_free(this_obj_conv);
10488 }
10489
10490 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
10491         unsigned char seed_arr[32];
10492         CHECK(*((uint32_t*)seed) == 32);
10493         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
10494         unsigned char (*seed_ref)[32] = &seed_arr;
10495         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
10496         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10497         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10498         long ret_ref = (long)ret_var.inner;
10499         if (ret_var.is_owned) {
10500                 ret_ref |= 1;
10501         }
10502         return ret_ref;
10503 }
10504
10505 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
10506         LDKKeysManager this_arg_conv;
10507         this_arg_conv.inner = (void*)(this_arg & (~1));
10508         this_arg_conv.is_owned = false;
10509         unsigned char params_arr[32];
10510         CHECK(*((uint32_t*)params) == 32);
10511         memcpy(params_arr, (uint8_t*)(params + 4), 32);
10512         unsigned char (*params_ref)[32] = &params_arr;
10513         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
10514         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10515         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10516         long ret_ref = (long)ret_var.inner;
10517         if (ret_var.is_owned) {
10518                 ret_ref |= 1;
10519         }
10520         return ret_ref;
10521 }
10522
10523 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) {
10524         LDKKeysManager this_arg_conv;
10525         this_arg_conv.inner = (void*)(this_arg & (~1));
10526         this_arg_conv.is_owned = false;
10527         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
10528         descriptors_constr.datalen = *((uint32_t*)descriptors);
10529         if (descriptors_constr.datalen > 0)
10530                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10531         else
10532                 descriptors_constr.data = NULL;
10533         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
10534         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
10535                 uint32_t descriptors_conv_27 = descriptors_vals[b];
10536                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
10537                 FREE((void*)descriptors_conv_27);
10538                 descriptors_constr.data[b] = descriptors_conv_27_conv;
10539         }
10540         LDKCVec_TxOutZ outputs_constr;
10541         outputs_constr.datalen = *((uint32_t*)outputs);
10542         if (outputs_constr.datalen > 0)
10543                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10544         else
10545                 outputs_constr.data = NULL;
10546         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
10547         for (size_t h = 0; h < outputs_constr.datalen; h++) {
10548                 uint32_t outputs_conv_7 = outputs_vals[h];
10549                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
10550                 FREE((void*)outputs_conv_7);
10551                 outputs_constr.data[h] = outputs_conv_7_conv;
10552         }
10553         LDKCVec_u8Z change_destination_script_ref;
10554         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
10555         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
10556         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
10557         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10558         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
10559         return (long)ret_conv;
10560 }
10561
10562 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
10563         LDKKeysManager this_arg_conv;
10564         this_arg_conv.inner = (void*)(this_arg & (~1));
10565         this_arg_conv.is_owned = false;
10566         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
10567         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
10568         return (long)ret;
10569 }
10570
10571 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
10572         LDKChannelManager this_obj_conv;
10573         this_obj_conv.inner = (void*)(this_obj & (~1));
10574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10575         ChannelManager_free(this_obj_conv);
10576 }
10577
10578 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
10579         LDKChainParameters this_obj_conv;
10580         this_obj_conv.inner = (void*)(this_obj & (~1));
10581         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10582         ChainParameters_free(this_obj_conv);
10583 }
10584
10585 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
10586         LDKChainParameters this_ptr_conv;
10587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10588         this_ptr_conv.is_owned = false;
10589         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
10590         return ret_conv;
10591 }
10592
10593 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
10594         LDKChainParameters this_ptr_conv;
10595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10596         this_ptr_conv.is_owned = false;
10597         LDKNetwork val_conv = LDKNetwork_from_js(val);
10598         ChainParameters_set_network(&this_ptr_conv, val_conv);
10599 }
10600
10601 int8_tArray  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_hash(uint32_t this_ptr) {
10602         LDKChainParameters this_ptr_conv;
10603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10604         this_ptr_conv.is_owned = false;
10605         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10606         memcpy((uint8_t*)(ret_arr + 4), *ChainParameters_get_latest_hash(&this_ptr_conv), 32);
10607         return ret_arr;
10608 }
10609
10610 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_hash(uint32_t this_ptr, int8_tArray val) {
10611         LDKChainParameters this_ptr_conv;
10612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10613         this_ptr_conv.is_owned = false;
10614         LDKThirtyTwoBytes val_ref;
10615         CHECK(*((uint32_t*)val) == 32);
10616         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10617         ChainParameters_set_latest_hash(&this_ptr_conv, val_ref);
10618 }
10619
10620 int64_t  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_height(uint32_t this_ptr) {
10621         LDKChainParameters this_ptr_conv;
10622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10623         this_ptr_conv.is_owned = false;
10624         int64_t ret_val = ChainParameters_get_latest_height(&this_ptr_conv);
10625         return ret_val;
10626 }
10627
10628 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_height(uint32_t this_ptr, int64_t val) {
10629         LDKChainParameters this_ptr_conv;
10630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10631         this_ptr_conv.is_owned = false;
10632         ChainParameters_set_latest_height(&this_ptr_conv, val);
10633 }
10634
10635 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, int8_tArray latest_hash_arg, int64_t latest_height_arg) {
10636         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
10637         LDKThirtyTwoBytes latest_hash_arg_ref;
10638         CHECK(*((uint32_t*)latest_hash_arg) == 32);
10639         memcpy(latest_hash_arg_ref.data, (uint8_t*)(latest_hash_arg + 4), 32);
10640         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, latest_hash_arg_ref, latest_height_arg);
10641         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10642         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10643         long ret_ref = (long)ret_var.inner;
10644         if (ret_var.is_owned) {
10645                 ret_ref |= 1;
10646         }
10647         return ret_ref;
10648 }
10649
10650 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
10651         LDKChannelDetails this_obj_conv;
10652         this_obj_conv.inner = (void*)(this_obj & (~1));
10653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10654         ChannelDetails_free(this_obj_conv);
10655 }
10656
10657 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
10658         LDKChannelDetails this_ptr_conv;
10659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10660         this_ptr_conv.is_owned = false;
10661         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10662         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
10663         return ret_arr;
10664 }
10665
10666 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10667         LDKChannelDetails this_ptr_conv;
10668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10669         this_ptr_conv.is_owned = false;
10670         LDKThirtyTwoBytes val_ref;
10671         CHECK(*((uint32_t*)val) == 32);
10672         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10673         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
10674 }
10675
10676 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
10677         LDKChannelDetails this_ptr_conv;
10678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10679         this_ptr_conv.is_owned = false;
10680         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10681         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
10682         return ret_arr;
10683 }
10684
10685 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
10686         LDKChannelDetails this_ptr_conv;
10687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10688         this_ptr_conv.is_owned = false;
10689         LDKPublicKey val_ref;
10690         CHECK(*((uint32_t*)val) == 33);
10691         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10692         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
10693 }
10694
10695 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
10696         LDKChannelDetails this_ptr_conv;
10697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10698         this_ptr_conv.is_owned = false;
10699         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
10700         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10701         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10702         long ret_ref = (long)ret_var.inner;
10703         if (ret_var.is_owned) {
10704                 ret_ref |= 1;
10705         }
10706         return ret_ref;
10707 }
10708
10709 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
10710         LDKChannelDetails this_ptr_conv;
10711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10712         this_ptr_conv.is_owned = false;
10713         LDKInitFeatures val_conv;
10714         val_conv.inner = (void*)(val & (~1));
10715         val_conv.is_owned = (val & 1) || (val == 0);
10716         val_conv = InitFeatures_clone(&val_conv);
10717         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
10718 }
10719
10720 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
10721         LDKChannelDetails this_ptr_conv;
10722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10723         this_ptr_conv.is_owned = false;
10724         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
10725         return ret_val;
10726 }
10727
10728 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10729         LDKChannelDetails this_ptr_conv;
10730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10731         this_ptr_conv.is_owned = false;
10732         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
10733 }
10734
10735 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
10736         LDKChannelDetails this_ptr_conv;
10737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10738         this_ptr_conv.is_owned = false;
10739         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
10740         return ret_val;
10741 }
10742
10743 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
10744         LDKChannelDetails this_ptr_conv;
10745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10746         this_ptr_conv.is_owned = false;
10747         ChannelDetails_set_user_id(&this_ptr_conv, val);
10748 }
10749
10750 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
10751         LDKChannelDetails this_ptr_conv;
10752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10753         this_ptr_conv.is_owned = false;
10754         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
10755         return ret_val;
10756 }
10757
10758 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
10759         LDKChannelDetails this_ptr_conv;
10760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10761         this_ptr_conv.is_owned = false;
10762         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
10763 }
10764
10765 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
10766         LDKChannelDetails this_ptr_conv;
10767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10768         this_ptr_conv.is_owned = false;
10769         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
10770         return ret_val;
10771 }
10772
10773 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
10774         LDKChannelDetails this_ptr_conv;
10775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10776         this_ptr_conv.is_owned = false;
10777         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
10778 }
10779
10780 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
10781         LDKChannelDetails this_ptr_conv;
10782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10783         this_ptr_conv.is_owned = false;
10784         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
10785         return ret_val;
10786 }
10787
10788 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
10789         LDKChannelDetails this_ptr_conv;
10790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10791         this_ptr_conv.is_owned = false;
10792         ChannelDetails_set_is_live(&this_ptr_conv, val);
10793 }
10794
10795 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
10796         LDKChannelDetails orig_conv;
10797         orig_conv.inner = (void*)(orig & (~1));
10798         orig_conv.is_owned = false;
10799         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
10800         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10801         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10802         long ret_ref = (long)ret_var.inner;
10803         if (ret_var.is_owned) {
10804                 ret_ref |= 1;
10805         }
10806         return ret_ref;
10807 }
10808
10809 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
10810         if ((this_ptr & 1) != 0) return;
10811         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
10812         FREE((void*)this_ptr);
10813         PaymentSendFailure_free(this_ptr_conv);
10814 }
10815
10816 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
10817         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
10818         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
10819         *ret_copy = PaymentSendFailure_clone(orig_conv);
10820         long ret_ref = (long)ret_copy;
10821         return ret_ref;
10822 }
10823
10824 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) {
10825         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
10826         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
10827         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
10828         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10829         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
10830         LDKUserConfig config_conv;
10831         config_conv.inner = (void*)(config & (~1));
10832         config_conv.is_owned = (config & 1) || (config == 0);
10833         config_conv = UserConfig_clone(&config_conv);
10834         LDKChainParameters params_conv;
10835         params_conv.inner = (void*)(params & (~1));
10836         params_conv.is_owned = (params & 1) || (params == 0);
10837         // Warning: we need a move here but no clone is available for LDKChainParameters
10838         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
10839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10841         long ret_ref = (long)ret_var.inner;
10842         if (ret_var.is_owned) {
10843                 ret_ref |= 1;
10844         }
10845         return ret_ref;
10846 }
10847
10848 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, uint32_t override_config) {
10849         LDKChannelManager this_arg_conv;
10850         this_arg_conv.inner = (void*)(this_arg & (~1));
10851         this_arg_conv.is_owned = false;
10852         LDKPublicKey their_network_key_ref;
10853         CHECK(*((uint32_t*)their_network_key) == 33);
10854         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
10855         LDKUserConfig override_config_conv;
10856         override_config_conv.inner = (void*)(override_config & (~1));
10857         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
10858         override_config_conv = UserConfig_clone(&override_config_conv);
10859         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10860         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
10861         return (long)ret_conv;
10862 }
10863
10864 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
10865         LDKChannelManager this_arg_conv;
10866         this_arg_conv.inner = (void*)(this_arg & (~1));
10867         this_arg_conv.is_owned = false;
10868         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
10869         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10870         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10871         for (size_t q = 0; q < ret_var.datalen; q++) {
10872                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10873                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10874                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10875                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
10876                 if (ret_conv_16_var.is_owned) {
10877                         ret_conv_16_ref |= 1;
10878                 }
10879                 ret_arr_ptr[q] = ret_conv_16_ref;
10880         }
10881         FREE(ret_var.data);
10882         return ret_arr;
10883 }
10884
10885 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
10886         LDKChannelManager this_arg_conv;
10887         this_arg_conv.inner = (void*)(this_arg & (~1));
10888         this_arg_conv.is_owned = false;
10889         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
10890         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10891         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10892         for (size_t q = 0; q < ret_var.datalen; q++) {
10893                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10894                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10895                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10896                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
10897                 if (ret_conv_16_var.is_owned) {
10898                         ret_conv_16_ref |= 1;
10899                 }
10900                 ret_arr_ptr[q] = ret_conv_16_ref;
10901         }
10902         FREE(ret_var.data);
10903         return ret_arr;
10904 }
10905
10906 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
10907         LDKChannelManager this_arg_conv;
10908         this_arg_conv.inner = (void*)(this_arg & (~1));
10909         this_arg_conv.is_owned = false;
10910         unsigned char channel_id_arr[32];
10911         CHECK(*((uint32_t*)channel_id) == 32);
10912         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
10913         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
10914         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10915         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
10916         return (long)ret_conv;
10917 }
10918
10919 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
10920         LDKChannelManager this_arg_conv;
10921         this_arg_conv.inner = (void*)(this_arg & (~1));
10922         this_arg_conv.is_owned = false;
10923         unsigned char channel_id_arr[32];
10924         CHECK(*((uint32_t*)channel_id) == 32);
10925         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
10926         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
10927         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10928         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
10929         return (long)ret_conv;
10930 }
10931
10932 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
10933         LDKChannelManager this_arg_conv;
10934         this_arg_conv.inner = (void*)(this_arg & (~1));
10935         this_arg_conv.is_owned = false;
10936         ChannelManager_force_close_all_channels(&this_arg_conv);
10937 }
10938
10939 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
10940         LDKChannelManager this_arg_conv;
10941         this_arg_conv.inner = (void*)(this_arg & (~1));
10942         this_arg_conv.is_owned = false;
10943         LDKRoute route_conv;
10944         route_conv.inner = (void*)(route & (~1));
10945         route_conv.is_owned = false;
10946         LDKThirtyTwoBytes payment_hash_ref;
10947         CHECK(*((uint32_t*)payment_hash) == 32);
10948         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
10949         LDKThirtyTwoBytes payment_secret_ref;
10950         CHECK(*((uint32_t*)payment_secret) == 32);
10951         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
10952         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10953         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
10954         return (long)ret_conv;
10955 }
10956
10957 void  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
10958         LDKChannelManager this_arg_conv;
10959         this_arg_conv.inner = (void*)(this_arg & (~1));
10960         this_arg_conv.is_owned = false;
10961         unsigned char temporary_channel_id_arr[32];
10962         CHECK(*((uint32_t*)temporary_channel_id) == 32);
10963         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
10964         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
10965         LDKOutPoint funding_txo_conv;
10966         funding_txo_conv.inner = (void*)(funding_txo & (~1));
10967         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
10968         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
10969         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
10970 }
10971
10972 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
10973         LDKChannelManager this_arg_conv;
10974         this_arg_conv.inner = (void*)(this_arg & (~1));
10975         this_arg_conv.is_owned = false;
10976         LDKThreeBytes rgb_ref;
10977         CHECK(*((uint32_t*)rgb) == 3);
10978         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
10979         LDKThirtyTwoBytes alias_ref;
10980         CHECK(*((uint32_t*)alias) == 32);
10981         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
10982         LDKCVec_NetAddressZ addresses_constr;
10983         addresses_constr.datalen = *((uint32_t*)addresses);
10984         if (addresses_constr.datalen > 0)
10985                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10986         else
10987                 addresses_constr.data = NULL;
10988         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
10989         for (size_t m = 0; m < addresses_constr.datalen; m++) {
10990                 uint32_t addresses_conv_12 = addresses_vals[m];
10991                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
10992                 FREE((void*)addresses_conv_12);
10993                 addresses_constr.data[m] = addresses_conv_12_conv;
10994         }
10995         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
10996 }
10997
10998 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
10999         LDKChannelManager this_arg_conv;
11000         this_arg_conv.inner = (void*)(this_arg & (~1));
11001         this_arg_conv.is_owned = false;
11002         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11003 }
11004
11005 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
11006         LDKChannelManager this_arg_conv;
11007         this_arg_conv.inner = (void*)(this_arg & (~1));
11008         this_arg_conv.is_owned = false;
11009         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
11010 }
11011
11012 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11013         LDKChannelManager this_arg_conv;
11014         this_arg_conv.inner = (void*)(this_arg & (~1));
11015         this_arg_conv.is_owned = false;
11016         unsigned char payment_hash_arr[32];
11017         CHECK(*((uint32_t*)payment_hash) == 32);
11018         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
11019         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11020         LDKThirtyTwoBytes payment_secret_ref;
11021         CHECK(*((uint32_t*)payment_secret) == 32);
11022         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11023         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11024         return ret_val;
11025 }
11026
11027 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11028         LDKChannelManager this_arg_conv;
11029         this_arg_conv.inner = (void*)(this_arg & (~1));
11030         this_arg_conv.is_owned = false;
11031         LDKThirtyTwoBytes payment_preimage_ref;
11032         CHECK(*((uint32_t*)payment_preimage) == 32);
11033         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11034         LDKThirtyTwoBytes payment_secret_ref;
11035         CHECK(*((uint32_t*)payment_secret) == 32);
11036         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11037         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
11038         return ret_val;
11039 }
11040
11041 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
11042         LDKChannelManager this_arg_conv;
11043         this_arg_conv.inner = (void*)(this_arg & (~1));
11044         this_arg_conv.is_owned = false;
11045         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11046         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
11047         return ret_arr;
11048 }
11049
11050 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
11051         LDKChannelManager this_arg_conv;
11052         this_arg_conv.inner = (void*)(this_arg & (~1));
11053         this_arg_conv.is_owned = false;
11054         LDKOutPoint funding_txo_conv;
11055         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11056         funding_txo_conv.is_owned = false;
11057         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
11058 }
11059
11060 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
11061         LDKChannelManager this_arg_conv;
11062         this_arg_conv.inner = (void*)(this_arg & (~1));
11063         this_arg_conv.is_owned = false;
11064         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11065         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
11066         return (long)ret;
11067 }
11068
11069 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
11070         LDKChannelManager this_arg_conv;
11071         this_arg_conv.inner = (void*)(this_arg & (~1));
11072         this_arg_conv.is_owned = false;
11073         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11074         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
11075         return (long)ret;
11076 }
11077
11078 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
11079         LDKChannelManager this_arg_conv;
11080         this_arg_conv.inner = (void*)(this_arg & (~1));
11081         this_arg_conv.is_owned = false;
11082         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11083         *ret = ChannelManager_as_Listen(&this_arg_conv);
11084         return (long)ret;
11085 }
11086
11087 void  __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
11088         LDKChannelManager this_arg_conv;
11089         this_arg_conv.inner = (void*)(this_arg & (~1));
11090         this_arg_conv.is_owned = false;
11091         unsigned char header_arr[80];
11092         CHECK(*((uint32_t*)header) == 80);
11093         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11094         unsigned char (*header_ref)[80] = &header_arr;
11095         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11096         txdata_constr.datalen = *((uint32_t*)txdata);
11097         if (txdata_constr.datalen > 0)
11098                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11099         else
11100                 txdata_constr.data = NULL;
11101         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11102         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11103                 uint32_t txdata_conv_30 = txdata_vals[e];
11104                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11105                 FREE((void*)txdata_conv_30);
11106                 txdata_constr.data[e] = txdata_conv_30_conv;
11107         }
11108         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11109 }
11110
11111 void  __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
11112         LDKChannelManager this_arg_conv;
11113         this_arg_conv.inner = (void*)(this_arg & (~1));
11114         this_arg_conv.is_owned = false;
11115         unsigned char header_arr[80];
11116         CHECK(*((uint32_t*)header) == 80);
11117         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11118         unsigned char (*header_ref)[80] = &header_arr;
11119         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
11120 }
11121
11122 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
11123         LDKChannelManager this_arg_conv;
11124         this_arg_conv.inner = (void*)(this_arg & (~1));
11125         this_arg_conv.is_owned = false;
11126         ChannelManager_await_persistable_update(&this_arg_conv);
11127 }
11128
11129 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
11130         LDKChannelManager this_arg_conv;
11131         this_arg_conv.inner = (void*)(this_arg & (~1));
11132         this_arg_conv.is_owned = false;
11133         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11134         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
11135         return (long)ret;
11136 }
11137
11138 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
11139         LDKChannelManager obj_conv;
11140         obj_conv.inner = (void*)(obj & (~1));
11141         obj_conv.is_owned = false;
11142         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
11143         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11144         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11145         CVec_u8Z_free(ret_var);
11146         return ret_arr;
11147 }
11148
11149 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
11150         LDKChannelManagerReadArgs this_obj_conv;
11151         this_obj_conv.inner = (void*)(this_obj & (~1));
11152         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11153         ChannelManagerReadArgs_free(this_obj_conv);
11154 }
11155
11156 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
11157         LDKChannelManagerReadArgs this_ptr_conv;
11158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11159         this_ptr_conv.is_owned = false;
11160         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
11161         return ret_ret;
11162 }
11163
11164 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
11165         LDKChannelManagerReadArgs this_ptr_conv;
11166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11167         this_ptr_conv.is_owned = false;
11168         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
11169         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
11170 }
11171
11172 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
11173         LDKChannelManagerReadArgs this_ptr_conv;
11174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11175         this_ptr_conv.is_owned = false;
11176         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
11177         return ret_ret;
11178 }
11179
11180 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
11181         LDKChannelManagerReadArgs this_ptr_conv;
11182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11183         this_ptr_conv.is_owned = false;
11184         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
11185         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
11186 }
11187
11188 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
11189         LDKChannelManagerReadArgs this_ptr_conv;
11190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11191         this_ptr_conv.is_owned = false;
11192         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
11193         return ret_ret;
11194 }
11195
11196 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
11197         LDKChannelManagerReadArgs this_ptr_conv;
11198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11199         this_ptr_conv.is_owned = false;
11200         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
11201         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
11202 }
11203
11204 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
11205         LDKChannelManagerReadArgs this_ptr_conv;
11206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11207         this_ptr_conv.is_owned = false;
11208         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
11209         return ret_ret;
11210 }
11211
11212 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
11213         LDKChannelManagerReadArgs this_ptr_conv;
11214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11215         this_ptr_conv.is_owned = false;
11216         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
11217         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
11218 }
11219
11220 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
11221         LDKChannelManagerReadArgs this_ptr_conv;
11222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11223         this_ptr_conv.is_owned = false;
11224         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
11225         return ret_ret;
11226 }
11227
11228 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
11229         LDKChannelManagerReadArgs this_ptr_conv;
11230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11231         this_ptr_conv.is_owned = false;
11232         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
11233         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
11234 }
11235
11236 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
11237         LDKChannelManagerReadArgs this_ptr_conv;
11238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11239         this_ptr_conv.is_owned = false;
11240         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
11241         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11242         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11243         long ret_ref = (long)ret_var.inner;
11244         if (ret_var.is_owned) {
11245                 ret_ref |= 1;
11246         }
11247         return ret_ref;
11248 }
11249
11250 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
11251         LDKChannelManagerReadArgs this_ptr_conv;
11252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11253         this_ptr_conv.is_owned = false;
11254         LDKUserConfig val_conv;
11255         val_conv.inner = (void*)(val & (~1));
11256         val_conv.is_owned = (val & 1) || (val == 0);
11257         val_conv = UserConfig_clone(&val_conv);
11258         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
11259 }
11260
11261 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) {
11262         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11263         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11264         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11265         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11266         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11267         LDKUserConfig default_config_conv;
11268         default_config_conv.inner = (void*)(default_config & (~1));
11269         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
11270         default_config_conv = UserConfig_clone(&default_config_conv);
11271         LDKCVec_ChannelMonitorZ channel_monitors_constr;
11272         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
11273         if (channel_monitors_constr.datalen > 0)
11274                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11275         else
11276                 channel_monitors_constr.data = NULL;
11277         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
11278         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
11279                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
11280                 LDKChannelMonitor channel_monitors_conv_16_conv;
11281                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
11282                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
11283                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
11284         }
11285         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);
11286         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11287         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11288         long ret_ref = (long)ret_var.inner;
11289         if (ret_var.is_owned) {
11290                 ret_ref |= 1;
11291         }
11292         return ret_ref;
11293 }
11294
11295 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
11296         LDKu8slice ser_ref;
11297         ser_ref.datalen = *((uint32_t*)ser);
11298         ser_ref.data = (int8_t*)(ser + 4);
11299         LDKChannelManagerReadArgs arg_conv;
11300         arg_conv.inner = (void*)(arg & (~1));
11301         arg_conv.is_owned = (arg & 1) || (arg == 0);
11302         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
11303         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11304         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
11305         return (long)ret_conv;
11306 }
11307
11308 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
11309         LDKDecodeError this_obj_conv;
11310         this_obj_conv.inner = (void*)(this_obj & (~1));
11311         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11312         DecodeError_free(this_obj_conv);
11313 }
11314
11315 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
11316         LDKDecodeError orig_conv;
11317         orig_conv.inner = (void*)(orig & (~1));
11318         orig_conv.is_owned = false;
11319         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
11320         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11321         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11322         long ret_ref = (long)ret_var.inner;
11323         if (ret_var.is_owned) {
11324                 ret_ref |= 1;
11325         }
11326         return ret_ref;
11327 }
11328
11329 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
11330         LDKInit this_obj_conv;
11331         this_obj_conv.inner = (void*)(this_obj & (~1));
11332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11333         Init_free(this_obj_conv);
11334 }
11335
11336 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
11337         LDKInit this_ptr_conv;
11338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11339         this_ptr_conv.is_owned = false;
11340         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
11341         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11342         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11343         long ret_ref = (long)ret_var.inner;
11344         if (ret_var.is_owned) {
11345                 ret_ref |= 1;
11346         }
11347         return ret_ref;
11348 }
11349
11350 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
11351         LDKInit this_ptr_conv;
11352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11353         this_ptr_conv.is_owned = false;
11354         LDKInitFeatures val_conv;
11355         val_conv.inner = (void*)(val & (~1));
11356         val_conv.is_owned = (val & 1) || (val == 0);
11357         val_conv = InitFeatures_clone(&val_conv);
11358         Init_set_features(&this_ptr_conv, val_conv);
11359 }
11360
11361 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
11362         LDKInitFeatures features_arg_conv;
11363         features_arg_conv.inner = (void*)(features_arg & (~1));
11364         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
11365         features_arg_conv = InitFeatures_clone(&features_arg_conv);
11366         LDKInit ret_var = Init_new(features_arg_conv);
11367         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11368         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11369         long ret_ref = (long)ret_var.inner;
11370         if (ret_var.is_owned) {
11371                 ret_ref |= 1;
11372         }
11373         return ret_ref;
11374 }
11375
11376 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
11377         LDKInit orig_conv;
11378         orig_conv.inner = (void*)(orig & (~1));
11379         orig_conv.is_owned = false;
11380         LDKInit ret_var = Init_clone(&orig_conv);
11381         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11382         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11383         long ret_ref = (long)ret_var.inner;
11384         if (ret_var.is_owned) {
11385                 ret_ref |= 1;
11386         }
11387         return ret_ref;
11388 }
11389
11390 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
11391         LDKErrorMessage this_obj_conv;
11392         this_obj_conv.inner = (void*)(this_obj & (~1));
11393         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11394         ErrorMessage_free(this_obj_conv);
11395 }
11396
11397 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
11398         LDKErrorMessage this_ptr_conv;
11399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11400         this_ptr_conv.is_owned = false;
11401         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11402         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
11403         return ret_arr;
11404 }
11405
11406 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
11407         LDKErrorMessage this_ptr_conv;
11408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11409         this_ptr_conv.is_owned = false;
11410         LDKThirtyTwoBytes val_ref;
11411         CHECK(*((uint32_t*)val) == 32);
11412         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11413         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
11414 }
11415
11416 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
11417         LDKErrorMessage this_ptr_conv;
11418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11419         this_ptr_conv.is_owned = false;
11420         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
11421         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11422         return _conv;
11423 }
11424
11425 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
11426         LDKErrorMessage this_ptr_conv;
11427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11428         this_ptr_conv.is_owned = false;
11429         LDKCVec_u8Z val_ref;
11430         val_ref.datalen = *((uint32_t*)val);
11431         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11432         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11433         ErrorMessage_set_data(&this_ptr_conv, val_ref);
11434 }
11435
11436 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
11437         LDKThirtyTwoBytes channel_id_arg_ref;
11438         CHECK(*((uint32_t*)channel_id_arg) == 32);
11439         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
11440         LDKCVec_u8Z data_arg_ref;
11441         data_arg_ref.datalen = *((uint32_t*)data_arg);
11442         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11443         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
11444         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
11445         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11446         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11447         long ret_ref = (long)ret_var.inner;
11448         if (ret_var.is_owned) {
11449                 ret_ref |= 1;
11450         }
11451         return ret_ref;
11452 }
11453
11454 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
11455         LDKErrorMessage orig_conv;
11456         orig_conv.inner = (void*)(orig & (~1));
11457         orig_conv.is_owned = false;
11458         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
11459         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11460         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11461         long ret_ref = (long)ret_var.inner;
11462         if (ret_var.is_owned) {
11463                 ret_ref |= 1;
11464         }
11465         return ret_ref;
11466 }
11467
11468 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
11469         LDKPing this_obj_conv;
11470         this_obj_conv.inner = (void*)(this_obj & (~1));
11471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11472         Ping_free(this_obj_conv);
11473 }
11474
11475 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
11476         LDKPing this_ptr_conv;
11477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11478         this_ptr_conv.is_owned = false;
11479         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
11480         return ret_val;
11481 }
11482
11483 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
11484         LDKPing this_ptr_conv;
11485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11486         this_ptr_conv.is_owned = false;
11487         Ping_set_ponglen(&this_ptr_conv, val);
11488 }
11489
11490 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
11491         LDKPing this_ptr_conv;
11492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11493         this_ptr_conv.is_owned = false;
11494         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
11495         return ret_val;
11496 }
11497
11498 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
11499         LDKPing this_ptr_conv;
11500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11501         this_ptr_conv.is_owned = false;
11502         Ping_set_byteslen(&this_ptr_conv, val);
11503 }
11504
11505 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
11506         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
11507         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11508         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11509         long ret_ref = (long)ret_var.inner;
11510         if (ret_var.is_owned) {
11511                 ret_ref |= 1;
11512         }
11513         return ret_ref;
11514 }
11515
11516 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
11517         LDKPing orig_conv;
11518         orig_conv.inner = (void*)(orig & (~1));
11519         orig_conv.is_owned = false;
11520         LDKPing ret_var = Ping_clone(&orig_conv);
11521         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11522         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11523         long ret_ref = (long)ret_var.inner;
11524         if (ret_var.is_owned) {
11525                 ret_ref |= 1;
11526         }
11527         return ret_ref;
11528 }
11529
11530 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
11531         LDKPong this_obj_conv;
11532         this_obj_conv.inner = (void*)(this_obj & (~1));
11533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11534         Pong_free(this_obj_conv);
11535 }
11536
11537 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
11538         LDKPong this_ptr_conv;
11539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11540         this_ptr_conv.is_owned = false;
11541         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
11542         return ret_val;
11543 }
11544
11545 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
11546         LDKPong this_ptr_conv;
11547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11548         this_ptr_conv.is_owned = false;
11549         Pong_set_byteslen(&this_ptr_conv, val);
11550 }
11551
11552 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
11553         LDKPong ret_var = Pong_new(byteslen_arg);
11554         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11555         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11556         long ret_ref = (long)ret_var.inner;
11557         if (ret_var.is_owned) {
11558                 ret_ref |= 1;
11559         }
11560         return ret_ref;
11561 }
11562
11563 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
11564         LDKPong orig_conv;
11565         orig_conv.inner = (void*)(orig & (~1));
11566         orig_conv.is_owned = false;
11567         LDKPong ret_var = Pong_clone(&orig_conv);
11568         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11569         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11570         long ret_ref = (long)ret_var.inner;
11571         if (ret_var.is_owned) {
11572                 ret_ref |= 1;
11573         }
11574         return ret_ref;
11575 }
11576
11577 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
11578         LDKOpenChannel this_obj_conv;
11579         this_obj_conv.inner = (void*)(this_obj & (~1));
11580         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11581         OpenChannel_free(this_obj_conv);
11582 }
11583
11584 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
11585         LDKOpenChannel this_ptr_conv;
11586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11587         this_ptr_conv.is_owned = false;
11588         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11589         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
11590         return ret_arr;
11591 }
11592
11593 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11594         LDKOpenChannel this_ptr_conv;
11595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11596         this_ptr_conv.is_owned = false;
11597         LDKThirtyTwoBytes val_ref;
11598         CHECK(*((uint32_t*)val) == 32);
11599         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11600         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
11601 }
11602
11603 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
11604         LDKOpenChannel this_ptr_conv;
11605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11606         this_ptr_conv.is_owned = false;
11607         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11608         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
11609         return ret_arr;
11610 }
11611
11612 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
11613         LDKOpenChannel this_ptr_conv;
11614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11615         this_ptr_conv.is_owned = false;
11616         LDKThirtyTwoBytes val_ref;
11617         CHECK(*((uint32_t*)val) == 32);
11618         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11619         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
11620 }
11621
11622 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
11623         LDKOpenChannel this_ptr_conv;
11624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11625         this_ptr_conv.is_owned = false;
11626         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
11627         return ret_val;
11628 }
11629
11630 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
11631         LDKOpenChannel this_ptr_conv;
11632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11633         this_ptr_conv.is_owned = false;
11634         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
11635 }
11636
11637 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
11638         LDKOpenChannel this_ptr_conv;
11639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11640         this_ptr_conv.is_owned = false;
11641         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
11642         return ret_val;
11643 }
11644
11645 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
11646         LDKOpenChannel this_ptr_conv;
11647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11648         this_ptr_conv.is_owned = false;
11649         OpenChannel_set_push_msat(&this_ptr_conv, val);
11650 }
11651
11652 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
11653         LDKOpenChannel this_ptr_conv;
11654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11655         this_ptr_conv.is_owned = false;
11656         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
11657         return ret_val;
11658 }
11659
11660 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
11661         LDKOpenChannel this_ptr_conv;
11662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11663         this_ptr_conv.is_owned = false;
11664         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
11665 }
11666
11667 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
11668         LDKOpenChannel this_ptr_conv;
11669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11670         this_ptr_conv.is_owned = false;
11671         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
11672         return ret_val;
11673 }
11674
11675 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
11676         LDKOpenChannel this_ptr_conv;
11677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11678         this_ptr_conv.is_owned = false;
11679         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
11680 }
11681
11682 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
11683         LDKOpenChannel this_ptr_conv;
11684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11685         this_ptr_conv.is_owned = false;
11686         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
11687         return ret_val;
11688 }
11689
11690 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11691         LDKOpenChannel this_ptr_conv;
11692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11693         this_ptr_conv.is_owned = false;
11694         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
11695 }
11696
11697 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
11698         LDKOpenChannel this_ptr_conv;
11699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11700         this_ptr_conv.is_owned = false;
11701         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
11702         return ret_val;
11703 }
11704
11705 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11706         LDKOpenChannel this_ptr_conv;
11707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11708         this_ptr_conv.is_owned = false;
11709         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
11710 }
11711
11712 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
11713         LDKOpenChannel this_ptr_conv;
11714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11715         this_ptr_conv.is_owned = false;
11716         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
11717         return ret_val;
11718 }
11719
11720 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
11721         LDKOpenChannel this_ptr_conv;
11722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11723         this_ptr_conv.is_owned = false;
11724         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
11725 }
11726
11727 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
11728         LDKOpenChannel this_ptr_conv;
11729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11730         this_ptr_conv.is_owned = false;
11731         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
11732         return ret_val;
11733 }
11734
11735 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
11736         LDKOpenChannel this_ptr_conv;
11737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11738         this_ptr_conv.is_owned = false;
11739         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
11740 }
11741
11742 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
11743         LDKOpenChannel this_ptr_conv;
11744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11745         this_ptr_conv.is_owned = false;
11746         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
11747         return ret_val;
11748 }
11749
11750 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
11751         LDKOpenChannel this_ptr_conv;
11752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11753         this_ptr_conv.is_owned = false;
11754         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
11755 }
11756
11757 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
11758         LDKOpenChannel this_ptr_conv;
11759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11760         this_ptr_conv.is_owned = false;
11761         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11762         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
11763         return ret_arr;
11764 }
11765
11766 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
11767         LDKOpenChannel this_ptr_conv;
11768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11769         this_ptr_conv.is_owned = false;
11770         LDKPublicKey val_ref;
11771         CHECK(*((uint32_t*)val) == 33);
11772         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11773         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
11774 }
11775
11776 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
11777         LDKOpenChannel this_ptr_conv;
11778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11779         this_ptr_conv.is_owned = false;
11780         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11781         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
11782         return ret_arr;
11783 }
11784
11785 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
11786         LDKOpenChannel this_ptr_conv;
11787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11788         this_ptr_conv.is_owned = false;
11789         LDKPublicKey val_ref;
11790         CHECK(*((uint32_t*)val) == 33);
11791         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11792         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
11793 }
11794
11795 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
11796         LDKOpenChannel this_ptr_conv;
11797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11798         this_ptr_conv.is_owned = false;
11799         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11800         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
11801         return ret_arr;
11802 }
11803
11804 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
11805         LDKOpenChannel this_ptr_conv;
11806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11807         this_ptr_conv.is_owned = false;
11808         LDKPublicKey val_ref;
11809         CHECK(*((uint32_t*)val) == 33);
11810         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11811         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
11812 }
11813
11814 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
11815         LDKOpenChannel this_ptr_conv;
11816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11817         this_ptr_conv.is_owned = false;
11818         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11819         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
11820         return ret_arr;
11821 }
11822
11823 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
11824         LDKOpenChannel this_ptr_conv;
11825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11826         this_ptr_conv.is_owned = false;
11827         LDKPublicKey val_ref;
11828         CHECK(*((uint32_t*)val) == 33);
11829         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11830         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11831 }
11832
11833 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
11834         LDKOpenChannel this_ptr_conv;
11835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11836         this_ptr_conv.is_owned = false;
11837         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11838         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
11839         return ret_arr;
11840 }
11841
11842 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
11843         LDKOpenChannel this_ptr_conv;
11844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11845         this_ptr_conv.is_owned = false;
11846         LDKPublicKey val_ref;
11847         CHECK(*((uint32_t*)val) == 33);
11848         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11849         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
11850 }
11851
11852 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
11853         LDKOpenChannel this_ptr_conv;
11854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11855         this_ptr_conv.is_owned = false;
11856         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11857         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
11858         return ret_arr;
11859 }
11860
11861 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
11862         LDKOpenChannel this_ptr_conv;
11863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11864         this_ptr_conv.is_owned = false;
11865         LDKPublicKey val_ref;
11866         CHECK(*((uint32_t*)val) == 33);
11867         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11868         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
11869 }
11870
11871 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
11872         LDKOpenChannel this_ptr_conv;
11873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11874         this_ptr_conv.is_owned = false;
11875         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
11876         return ret_val;
11877 }
11878
11879 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
11880         LDKOpenChannel this_ptr_conv;
11881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11882         this_ptr_conv.is_owned = false;
11883         OpenChannel_set_channel_flags(&this_ptr_conv, val);
11884 }
11885
11886 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
11887         LDKOpenChannel orig_conv;
11888         orig_conv.inner = (void*)(orig & (~1));
11889         orig_conv.is_owned = false;
11890         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
11891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11893         long ret_ref = (long)ret_var.inner;
11894         if (ret_var.is_owned) {
11895                 ret_ref |= 1;
11896         }
11897         return ret_ref;
11898 }
11899
11900 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
11901         LDKAcceptChannel this_obj_conv;
11902         this_obj_conv.inner = (void*)(this_obj & (~1));
11903         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11904         AcceptChannel_free(this_obj_conv);
11905 }
11906
11907 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
11908         LDKAcceptChannel this_ptr_conv;
11909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11910         this_ptr_conv.is_owned = false;
11911         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11912         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
11913         return ret_arr;
11914 }
11915
11916 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
11917         LDKAcceptChannel this_ptr_conv;
11918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11919         this_ptr_conv.is_owned = false;
11920         LDKThirtyTwoBytes val_ref;
11921         CHECK(*((uint32_t*)val) == 32);
11922         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11923         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
11924 }
11925
11926 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
11927         LDKAcceptChannel this_ptr_conv;
11928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11929         this_ptr_conv.is_owned = false;
11930         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
11931         return ret_val;
11932 }
11933
11934 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
11935         LDKAcceptChannel this_ptr_conv;
11936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11937         this_ptr_conv.is_owned = false;
11938         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
11939 }
11940
11941 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
11942         LDKAcceptChannel this_ptr_conv;
11943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11944         this_ptr_conv.is_owned = false;
11945         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
11946         return ret_val;
11947 }
11948
11949 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
11950         LDKAcceptChannel this_ptr_conv;
11951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11952         this_ptr_conv.is_owned = false;
11953         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
11954 }
11955
11956 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
11957         LDKAcceptChannel this_ptr_conv;
11958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11959         this_ptr_conv.is_owned = false;
11960         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
11961         return ret_val;
11962 }
11963
11964 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11965         LDKAcceptChannel this_ptr_conv;
11966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11967         this_ptr_conv.is_owned = false;
11968         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
11969 }
11970
11971 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
11972         LDKAcceptChannel this_ptr_conv;
11973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11974         this_ptr_conv.is_owned = false;
11975         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
11976         return ret_val;
11977 }
11978
11979 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11980         LDKAcceptChannel this_ptr_conv;
11981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11982         this_ptr_conv.is_owned = false;
11983         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
11984 }
11985
11986 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
11987         LDKAcceptChannel this_ptr_conv;
11988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11989         this_ptr_conv.is_owned = false;
11990         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
11991         return ret_val;
11992 }
11993
11994 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
11995         LDKAcceptChannel this_ptr_conv;
11996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11997         this_ptr_conv.is_owned = false;
11998         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
11999 }
12000
12001 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
12002         LDKAcceptChannel this_ptr_conv;
12003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12004         this_ptr_conv.is_owned = false;
12005         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
12006         return ret_val;
12007 }
12008
12009 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12010         LDKAcceptChannel this_ptr_conv;
12011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12012         this_ptr_conv.is_owned = false;
12013         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
12014 }
12015
12016 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12017         LDKAcceptChannel this_ptr_conv;
12018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12019         this_ptr_conv.is_owned = false;
12020         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
12021         return ret_val;
12022 }
12023
12024 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12025         LDKAcceptChannel this_ptr_conv;
12026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12027         this_ptr_conv.is_owned = false;
12028         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12029 }
12030
12031 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
12032         LDKAcceptChannel this_ptr_conv;
12033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12034         this_ptr_conv.is_owned = false;
12035         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12036         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12037         return ret_arr;
12038 }
12039
12040 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12041         LDKAcceptChannel this_ptr_conv;
12042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12043         this_ptr_conv.is_owned = false;
12044         LDKPublicKey val_ref;
12045         CHECK(*((uint32_t*)val) == 33);
12046         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12047         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12048 }
12049
12050 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
12051         LDKAcceptChannel this_ptr_conv;
12052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12053         this_ptr_conv.is_owned = false;
12054         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12055         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12056         return ret_arr;
12057 }
12058
12059 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12060         LDKAcceptChannel this_ptr_conv;
12061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12062         this_ptr_conv.is_owned = false;
12063         LDKPublicKey val_ref;
12064         CHECK(*((uint32_t*)val) == 33);
12065         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12066         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12067 }
12068
12069 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
12070         LDKAcceptChannel this_ptr_conv;
12071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12072         this_ptr_conv.is_owned = false;
12073         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12074         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12075         return ret_arr;
12076 }
12077
12078 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12079         LDKAcceptChannel this_ptr_conv;
12080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12081         this_ptr_conv.is_owned = false;
12082         LDKPublicKey val_ref;
12083         CHECK(*((uint32_t*)val) == 33);
12084         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12085         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
12086 }
12087
12088 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12089         LDKAcceptChannel this_ptr_conv;
12090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12091         this_ptr_conv.is_owned = false;
12092         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12093         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12094         return ret_arr;
12095 }
12096
12097 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12098         LDKAcceptChannel this_ptr_conv;
12099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12100         this_ptr_conv.is_owned = false;
12101         LDKPublicKey val_ref;
12102         CHECK(*((uint32_t*)val) == 33);
12103         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12104         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12105 }
12106
12107 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
12108         LDKAcceptChannel this_ptr_conv;
12109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12110         this_ptr_conv.is_owned = false;
12111         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12112         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12113         return ret_arr;
12114 }
12115
12116 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12117         LDKAcceptChannel this_ptr_conv;
12118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12119         this_ptr_conv.is_owned = false;
12120         LDKPublicKey val_ref;
12121         CHECK(*((uint32_t*)val) == 33);
12122         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12123         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12124 }
12125
12126 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12127         LDKAcceptChannel this_ptr_conv;
12128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12129         this_ptr_conv.is_owned = false;
12130         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12131         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12132         return ret_arr;
12133 }
12134
12135 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12136         LDKAcceptChannel this_ptr_conv;
12137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12138         this_ptr_conv.is_owned = false;
12139         LDKPublicKey val_ref;
12140         CHECK(*((uint32_t*)val) == 33);
12141         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12142         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12143 }
12144
12145 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
12146         LDKAcceptChannel orig_conv;
12147         orig_conv.inner = (void*)(orig & (~1));
12148         orig_conv.is_owned = false;
12149         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
12150         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12151         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12152         long ret_ref = (long)ret_var.inner;
12153         if (ret_var.is_owned) {
12154                 ret_ref |= 1;
12155         }
12156         return ret_ref;
12157 }
12158
12159 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
12160         LDKFundingCreated this_obj_conv;
12161         this_obj_conv.inner = (void*)(this_obj & (~1));
12162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12163         FundingCreated_free(this_obj_conv);
12164 }
12165
12166 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
12167         LDKFundingCreated this_ptr_conv;
12168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12169         this_ptr_conv.is_owned = false;
12170         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12171         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
12172         return ret_arr;
12173 }
12174
12175 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12176         LDKFundingCreated this_ptr_conv;
12177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12178         this_ptr_conv.is_owned = false;
12179         LDKThirtyTwoBytes val_ref;
12180         CHECK(*((uint32_t*)val) == 32);
12181         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12182         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
12183 }
12184
12185 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
12186         LDKFundingCreated this_ptr_conv;
12187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12188         this_ptr_conv.is_owned = false;
12189         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12190         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
12191         return ret_arr;
12192 }
12193
12194 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
12195         LDKFundingCreated this_ptr_conv;
12196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12197         this_ptr_conv.is_owned = false;
12198         LDKThirtyTwoBytes val_ref;
12199         CHECK(*((uint32_t*)val) == 32);
12200         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12201         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
12202 }
12203
12204 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
12205         LDKFundingCreated this_ptr_conv;
12206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12207         this_ptr_conv.is_owned = false;
12208         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
12209         return ret_val;
12210 }
12211
12212 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
12213         LDKFundingCreated this_ptr_conv;
12214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12215         this_ptr_conv.is_owned = false;
12216         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
12217 }
12218
12219 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
12220         LDKFundingCreated this_ptr_conv;
12221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12222         this_ptr_conv.is_owned = false;
12223         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12224         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
12225         return ret_arr;
12226 }
12227
12228 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
12229         LDKFundingCreated this_ptr_conv;
12230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12231         this_ptr_conv.is_owned = false;
12232         LDKSignature val_ref;
12233         CHECK(*((uint32_t*)val) == 64);
12234         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12235         FundingCreated_set_signature(&this_ptr_conv, val_ref);
12236 }
12237
12238 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) {
12239         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
12240         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
12241         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
12242         LDKThirtyTwoBytes funding_txid_arg_ref;
12243         CHECK(*((uint32_t*)funding_txid_arg) == 32);
12244         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
12245         LDKSignature signature_arg_ref;
12246         CHECK(*((uint32_t*)signature_arg) == 64);
12247         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12248         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
12249         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12250         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12251         long ret_ref = (long)ret_var.inner;
12252         if (ret_var.is_owned) {
12253                 ret_ref |= 1;
12254         }
12255         return ret_ref;
12256 }
12257
12258 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
12259         LDKFundingCreated orig_conv;
12260         orig_conv.inner = (void*)(orig & (~1));
12261         orig_conv.is_owned = false;
12262         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
12263         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12264         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12265         long ret_ref = (long)ret_var.inner;
12266         if (ret_var.is_owned) {
12267                 ret_ref |= 1;
12268         }
12269         return ret_ref;
12270 }
12271
12272 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
12273         LDKFundingSigned this_obj_conv;
12274         this_obj_conv.inner = (void*)(this_obj & (~1));
12275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12276         FundingSigned_free(this_obj_conv);
12277 }
12278
12279 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
12280         LDKFundingSigned this_ptr_conv;
12281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12282         this_ptr_conv.is_owned = false;
12283         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12284         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
12285         return ret_arr;
12286 }
12287
12288 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12289         LDKFundingSigned this_ptr_conv;
12290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12291         this_ptr_conv.is_owned = false;
12292         LDKThirtyTwoBytes val_ref;
12293         CHECK(*((uint32_t*)val) == 32);
12294         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12295         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
12296 }
12297
12298 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
12299         LDKFundingSigned this_ptr_conv;
12300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12301         this_ptr_conv.is_owned = false;
12302         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12303         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12304         return ret_arr;
12305 }
12306
12307 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12308         LDKFundingSigned this_ptr_conv;
12309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12310         this_ptr_conv.is_owned = false;
12311         LDKSignature val_ref;
12312         CHECK(*((uint32_t*)val) == 64);
12313         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12314         FundingSigned_set_signature(&this_ptr_conv, val_ref);
12315 }
12316
12317 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
12318         LDKThirtyTwoBytes channel_id_arg_ref;
12319         CHECK(*((uint32_t*)channel_id_arg) == 32);
12320         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12321         LDKSignature signature_arg_ref;
12322         CHECK(*((uint32_t*)signature_arg) == 64);
12323         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12324         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
12325         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12326         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12327         long ret_ref = (long)ret_var.inner;
12328         if (ret_var.is_owned) {
12329                 ret_ref |= 1;
12330         }
12331         return ret_ref;
12332 }
12333
12334 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
12335         LDKFundingSigned orig_conv;
12336         orig_conv.inner = (void*)(orig & (~1));
12337         orig_conv.is_owned = false;
12338         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
12339         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12340         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12341         long ret_ref = (long)ret_var.inner;
12342         if (ret_var.is_owned) {
12343                 ret_ref |= 1;
12344         }
12345         return ret_ref;
12346 }
12347
12348 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
12349         LDKFundingLocked this_obj_conv;
12350         this_obj_conv.inner = (void*)(this_obj & (~1));
12351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12352         FundingLocked_free(this_obj_conv);
12353 }
12354
12355 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
12356         LDKFundingLocked this_ptr_conv;
12357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12358         this_ptr_conv.is_owned = false;
12359         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12360         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
12361         return ret_arr;
12362 }
12363
12364 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12365         LDKFundingLocked this_ptr_conv;
12366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12367         this_ptr_conv.is_owned = false;
12368         LDKThirtyTwoBytes val_ref;
12369         CHECK(*((uint32_t*)val) == 32);
12370         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12371         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
12372 }
12373
12374 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
12375         LDKFundingLocked this_ptr_conv;
12376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12377         this_ptr_conv.is_owned = false;
12378         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12379         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12380         return ret_arr;
12381 }
12382
12383 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12384         LDKFundingLocked this_ptr_conv;
12385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12386         this_ptr_conv.is_owned = false;
12387         LDKPublicKey val_ref;
12388         CHECK(*((uint32_t*)val) == 33);
12389         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12390         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
12391 }
12392
12393 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
12394         LDKThirtyTwoBytes channel_id_arg_ref;
12395         CHECK(*((uint32_t*)channel_id_arg) == 32);
12396         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12397         LDKPublicKey next_per_commitment_point_arg_ref;
12398         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
12399         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
12400         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
12401         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12402         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12403         long ret_ref = (long)ret_var.inner;
12404         if (ret_var.is_owned) {
12405                 ret_ref |= 1;
12406         }
12407         return ret_ref;
12408 }
12409
12410 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
12411         LDKFundingLocked orig_conv;
12412         orig_conv.inner = (void*)(orig & (~1));
12413         orig_conv.is_owned = false;
12414         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
12415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12417         long ret_ref = (long)ret_var.inner;
12418         if (ret_var.is_owned) {
12419                 ret_ref |= 1;
12420         }
12421         return ret_ref;
12422 }
12423
12424 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
12425         LDKShutdown this_obj_conv;
12426         this_obj_conv.inner = (void*)(this_obj & (~1));
12427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12428         Shutdown_free(this_obj_conv);
12429 }
12430
12431 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
12432         LDKShutdown this_ptr_conv;
12433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12434         this_ptr_conv.is_owned = false;
12435         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12436         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
12437         return ret_arr;
12438 }
12439
12440 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12441         LDKShutdown this_ptr_conv;
12442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12443         this_ptr_conv.is_owned = false;
12444         LDKThirtyTwoBytes val_ref;
12445         CHECK(*((uint32_t*)val) == 32);
12446         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12447         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
12448 }
12449
12450 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
12451         LDKShutdown this_ptr_conv;
12452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12453         this_ptr_conv.is_owned = false;
12454         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
12455         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12456         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12457         return ret_arr;
12458 }
12459
12460 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
12461         LDKShutdown this_ptr_conv;
12462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12463         this_ptr_conv.is_owned = false;
12464         LDKCVec_u8Z val_ref;
12465         val_ref.datalen = *((uint32_t*)val);
12466         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12467         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
12468         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
12469 }
12470
12471 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
12472         LDKThirtyTwoBytes channel_id_arg_ref;
12473         CHECK(*((uint32_t*)channel_id_arg) == 32);
12474         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12475         LDKCVec_u8Z scriptpubkey_arg_ref;
12476         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
12477         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12478         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
12479         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
12480         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12481         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12482         long ret_ref = (long)ret_var.inner;
12483         if (ret_var.is_owned) {
12484                 ret_ref |= 1;
12485         }
12486         return ret_ref;
12487 }
12488
12489 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
12490         LDKShutdown orig_conv;
12491         orig_conv.inner = (void*)(orig & (~1));
12492         orig_conv.is_owned = false;
12493         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
12494         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12495         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12496         long ret_ref = (long)ret_var.inner;
12497         if (ret_var.is_owned) {
12498                 ret_ref |= 1;
12499         }
12500         return ret_ref;
12501 }
12502
12503 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
12504         LDKClosingSigned this_obj_conv;
12505         this_obj_conv.inner = (void*)(this_obj & (~1));
12506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12507         ClosingSigned_free(this_obj_conv);
12508 }
12509
12510 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
12511         LDKClosingSigned this_ptr_conv;
12512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12513         this_ptr_conv.is_owned = false;
12514         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12515         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
12516         return ret_arr;
12517 }
12518
12519 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12520         LDKClosingSigned this_ptr_conv;
12521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12522         this_ptr_conv.is_owned = false;
12523         LDKThirtyTwoBytes val_ref;
12524         CHECK(*((uint32_t*)val) == 32);
12525         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12526         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
12527 }
12528
12529 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
12530         LDKClosingSigned this_ptr_conv;
12531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12532         this_ptr_conv.is_owned = false;
12533         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
12534         return ret_val;
12535 }
12536
12537 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
12538         LDKClosingSigned this_ptr_conv;
12539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12540         this_ptr_conv.is_owned = false;
12541         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
12542 }
12543
12544 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
12545         LDKClosingSigned this_ptr_conv;
12546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12547         this_ptr_conv.is_owned = false;
12548         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12549         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12550         return ret_arr;
12551 }
12552
12553 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12554         LDKClosingSigned this_ptr_conv;
12555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12556         this_ptr_conv.is_owned = false;
12557         LDKSignature val_ref;
12558         CHECK(*((uint32_t*)val) == 64);
12559         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12560         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
12561 }
12562
12563 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
12564         LDKThirtyTwoBytes channel_id_arg_ref;
12565         CHECK(*((uint32_t*)channel_id_arg) == 32);
12566         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12567         LDKSignature signature_arg_ref;
12568         CHECK(*((uint32_t*)signature_arg) == 64);
12569         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12570         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
12571         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12572         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12573         long ret_ref = (long)ret_var.inner;
12574         if (ret_var.is_owned) {
12575                 ret_ref |= 1;
12576         }
12577         return ret_ref;
12578 }
12579
12580 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
12581         LDKClosingSigned orig_conv;
12582         orig_conv.inner = (void*)(orig & (~1));
12583         orig_conv.is_owned = false;
12584         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
12585         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12586         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12587         long ret_ref = (long)ret_var.inner;
12588         if (ret_var.is_owned) {
12589                 ret_ref |= 1;
12590         }
12591         return ret_ref;
12592 }
12593
12594 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
12595         LDKUpdateAddHTLC this_obj_conv;
12596         this_obj_conv.inner = (void*)(this_obj & (~1));
12597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12598         UpdateAddHTLC_free(this_obj_conv);
12599 }
12600
12601 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
12602         LDKUpdateAddHTLC this_ptr_conv;
12603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12604         this_ptr_conv.is_owned = false;
12605         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12606         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
12607         return ret_arr;
12608 }
12609
12610 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12611         LDKUpdateAddHTLC this_ptr_conv;
12612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12613         this_ptr_conv.is_owned = false;
12614         LDKThirtyTwoBytes val_ref;
12615         CHECK(*((uint32_t*)val) == 32);
12616         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12617         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
12618 }
12619
12620 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
12621         LDKUpdateAddHTLC this_ptr_conv;
12622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12623         this_ptr_conv.is_owned = false;
12624         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
12625         return ret_val;
12626 }
12627
12628 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12629         LDKUpdateAddHTLC this_ptr_conv;
12630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12631         this_ptr_conv.is_owned = false;
12632         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
12633 }
12634
12635 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
12636         LDKUpdateAddHTLC this_ptr_conv;
12637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12638         this_ptr_conv.is_owned = false;
12639         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
12640         return ret_val;
12641 }
12642
12643 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
12644         LDKUpdateAddHTLC this_ptr_conv;
12645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12646         this_ptr_conv.is_owned = false;
12647         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
12648 }
12649
12650 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
12651         LDKUpdateAddHTLC this_ptr_conv;
12652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12653         this_ptr_conv.is_owned = false;
12654         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12655         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
12656         return ret_arr;
12657 }
12658
12659 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
12660         LDKUpdateAddHTLC this_ptr_conv;
12661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12662         this_ptr_conv.is_owned = false;
12663         LDKThirtyTwoBytes val_ref;
12664         CHECK(*((uint32_t*)val) == 32);
12665         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12666         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
12667 }
12668
12669 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
12670         LDKUpdateAddHTLC this_ptr_conv;
12671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12672         this_ptr_conv.is_owned = false;
12673         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
12674         return ret_val;
12675 }
12676
12677 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
12678         LDKUpdateAddHTLC this_ptr_conv;
12679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12680         this_ptr_conv.is_owned = false;
12681         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
12682 }
12683
12684 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
12685         LDKUpdateAddHTLC orig_conv;
12686         orig_conv.inner = (void*)(orig & (~1));
12687         orig_conv.is_owned = false;
12688         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
12689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12691         long ret_ref = (long)ret_var.inner;
12692         if (ret_var.is_owned) {
12693                 ret_ref |= 1;
12694         }
12695         return ret_ref;
12696 }
12697
12698 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
12699         LDKUpdateFulfillHTLC this_obj_conv;
12700         this_obj_conv.inner = (void*)(this_obj & (~1));
12701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12702         UpdateFulfillHTLC_free(this_obj_conv);
12703 }
12704
12705 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
12706         LDKUpdateFulfillHTLC this_ptr_conv;
12707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12708         this_ptr_conv.is_owned = false;
12709         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12710         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
12711         return ret_arr;
12712 }
12713
12714 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12715         LDKUpdateFulfillHTLC this_ptr_conv;
12716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12717         this_ptr_conv.is_owned = false;
12718         LDKThirtyTwoBytes val_ref;
12719         CHECK(*((uint32_t*)val) == 32);
12720         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12721         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
12722 }
12723
12724 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
12725         LDKUpdateFulfillHTLC this_ptr_conv;
12726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12727         this_ptr_conv.is_owned = false;
12728         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
12729         return ret_val;
12730 }
12731
12732 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12733         LDKUpdateFulfillHTLC this_ptr_conv;
12734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12735         this_ptr_conv.is_owned = false;
12736         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
12737 }
12738
12739 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
12740         LDKUpdateFulfillHTLC this_ptr_conv;
12741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12742         this_ptr_conv.is_owned = false;
12743         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12744         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
12745         return ret_arr;
12746 }
12747
12748 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
12749         LDKUpdateFulfillHTLC this_ptr_conv;
12750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12751         this_ptr_conv.is_owned = false;
12752         LDKThirtyTwoBytes val_ref;
12753         CHECK(*((uint32_t*)val) == 32);
12754         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12755         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
12756 }
12757
12758 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
12759         LDKThirtyTwoBytes channel_id_arg_ref;
12760         CHECK(*((uint32_t*)channel_id_arg) == 32);
12761         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12762         LDKThirtyTwoBytes payment_preimage_arg_ref;
12763         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
12764         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
12765         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
12766         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12767         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12768         long ret_ref = (long)ret_var.inner;
12769         if (ret_var.is_owned) {
12770                 ret_ref |= 1;
12771         }
12772         return ret_ref;
12773 }
12774
12775 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
12776         LDKUpdateFulfillHTLC orig_conv;
12777         orig_conv.inner = (void*)(orig & (~1));
12778         orig_conv.is_owned = false;
12779         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
12780         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12781         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12782         long ret_ref = (long)ret_var.inner;
12783         if (ret_var.is_owned) {
12784                 ret_ref |= 1;
12785         }
12786         return ret_ref;
12787 }
12788
12789 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
12790         LDKUpdateFailHTLC this_obj_conv;
12791         this_obj_conv.inner = (void*)(this_obj & (~1));
12792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12793         UpdateFailHTLC_free(this_obj_conv);
12794 }
12795
12796 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
12797         LDKUpdateFailHTLC this_ptr_conv;
12798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12799         this_ptr_conv.is_owned = false;
12800         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12801         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
12802         return ret_arr;
12803 }
12804
12805 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12806         LDKUpdateFailHTLC this_ptr_conv;
12807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12808         this_ptr_conv.is_owned = false;
12809         LDKThirtyTwoBytes val_ref;
12810         CHECK(*((uint32_t*)val) == 32);
12811         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12812         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
12813 }
12814
12815 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
12816         LDKUpdateFailHTLC this_ptr_conv;
12817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12818         this_ptr_conv.is_owned = false;
12819         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
12820         return ret_val;
12821 }
12822
12823 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12824         LDKUpdateFailHTLC this_ptr_conv;
12825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12826         this_ptr_conv.is_owned = false;
12827         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
12828 }
12829
12830 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
12831         LDKUpdateFailHTLC orig_conv;
12832         orig_conv.inner = (void*)(orig & (~1));
12833         orig_conv.is_owned = false;
12834         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
12835         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12836         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12837         long ret_ref = (long)ret_var.inner;
12838         if (ret_var.is_owned) {
12839                 ret_ref |= 1;
12840         }
12841         return ret_ref;
12842 }
12843
12844 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
12845         LDKUpdateFailMalformedHTLC this_obj_conv;
12846         this_obj_conv.inner = (void*)(this_obj & (~1));
12847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12848         UpdateFailMalformedHTLC_free(this_obj_conv);
12849 }
12850
12851 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
12852         LDKUpdateFailMalformedHTLC this_ptr_conv;
12853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12854         this_ptr_conv.is_owned = false;
12855         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12856         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
12857         return ret_arr;
12858 }
12859
12860 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12861         LDKUpdateFailMalformedHTLC this_ptr_conv;
12862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12863         this_ptr_conv.is_owned = false;
12864         LDKThirtyTwoBytes val_ref;
12865         CHECK(*((uint32_t*)val) == 32);
12866         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12867         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
12868 }
12869
12870 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
12871         LDKUpdateFailMalformedHTLC this_ptr_conv;
12872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12873         this_ptr_conv.is_owned = false;
12874         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
12875         return ret_val;
12876 }
12877
12878 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12879         LDKUpdateFailMalformedHTLC this_ptr_conv;
12880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12881         this_ptr_conv.is_owned = false;
12882         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
12883 }
12884
12885 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
12886         LDKUpdateFailMalformedHTLC this_ptr_conv;
12887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12888         this_ptr_conv.is_owned = false;
12889         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
12890         return ret_val;
12891 }
12892
12893 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
12894         LDKUpdateFailMalformedHTLC this_ptr_conv;
12895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12896         this_ptr_conv.is_owned = false;
12897         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
12898 }
12899
12900 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
12901         LDKUpdateFailMalformedHTLC orig_conv;
12902         orig_conv.inner = (void*)(orig & (~1));
12903         orig_conv.is_owned = false;
12904         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
12905         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12906         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12907         long ret_ref = (long)ret_var.inner;
12908         if (ret_var.is_owned) {
12909                 ret_ref |= 1;
12910         }
12911         return ret_ref;
12912 }
12913
12914 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
12915         LDKCommitmentSigned this_obj_conv;
12916         this_obj_conv.inner = (void*)(this_obj & (~1));
12917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12918         CommitmentSigned_free(this_obj_conv);
12919 }
12920
12921 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
12922         LDKCommitmentSigned this_ptr_conv;
12923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12924         this_ptr_conv.is_owned = false;
12925         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12926         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
12927         return ret_arr;
12928 }
12929
12930 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12931         LDKCommitmentSigned this_ptr_conv;
12932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12933         this_ptr_conv.is_owned = false;
12934         LDKThirtyTwoBytes val_ref;
12935         CHECK(*((uint32_t*)val) == 32);
12936         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12937         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
12938 }
12939
12940 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
12941         LDKCommitmentSigned this_ptr_conv;
12942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12943         this_ptr_conv.is_owned = false;
12944         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12945         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
12946         return ret_arr;
12947 }
12948
12949 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12950         LDKCommitmentSigned this_ptr_conv;
12951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12952         this_ptr_conv.is_owned = false;
12953         LDKSignature val_ref;
12954         CHECK(*((uint32_t*)val) == 64);
12955         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12956         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
12957 }
12958
12959 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
12960         LDKCommitmentSigned this_ptr_conv;
12961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12962         this_ptr_conv.is_owned = false;
12963         LDKCVec_SignatureZ val_constr;
12964         val_constr.datalen = *((uint32_t*)val);
12965         if (val_constr.datalen > 0)
12966                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12967         else
12968                 val_constr.data = NULL;
12969         int8_tArray* val_vals = (int8_tArray*)(val + 4);
12970         for (size_t m = 0; m < val_constr.datalen; m++) {
12971                 int8_tArray val_conv_12 = val_vals[m];
12972                 LDKSignature val_conv_12_ref;
12973                 CHECK(*((uint32_t*)val_conv_12) == 64);
12974                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
12975                 val_constr.data[m] = val_conv_12_ref;
12976         }
12977         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
12978 }
12979
12980 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
12981         LDKThirtyTwoBytes channel_id_arg_ref;
12982         CHECK(*((uint32_t*)channel_id_arg) == 32);
12983         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12984         LDKSignature signature_arg_ref;
12985         CHECK(*((uint32_t*)signature_arg) == 64);
12986         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12987         LDKCVec_SignatureZ htlc_signatures_arg_constr;
12988         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
12989         if (htlc_signatures_arg_constr.datalen > 0)
12990                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12991         else
12992                 htlc_signatures_arg_constr.data = NULL;
12993         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
12994         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
12995                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
12996                 LDKSignature htlc_signatures_arg_conv_12_ref;
12997                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
12998                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
12999                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
13000         }
13001         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
13002         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13003         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13004         long ret_ref = (long)ret_var.inner;
13005         if (ret_var.is_owned) {
13006                 ret_ref |= 1;
13007         }
13008         return ret_ref;
13009 }
13010
13011 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
13012         LDKCommitmentSigned orig_conv;
13013         orig_conv.inner = (void*)(orig & (~1));
13014         orig_conv.is_owned = false;
13015         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
13016         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13017         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13018         long ret_ref = (long)ret_var.inner;
13019         if (ret_var.is_owned) {
13020                 ret_ref |= 1;
13021         }
13022         return ret_ref;
13023 }
13024
13025 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
13026         LDKRevokeAndACK this_obj_conv;
13027         this_obj_conv.inner = (void*)(this_obj & (~1));
13028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13029         RevokeAndACK_free(this_obj_conv);
13030 }
13031
13032 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
13033         LDKRevokeAndACK this_ptr_conv;
13034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13035         this_ptr_conv.is_owned = false;
13036         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13037         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
13038         return ret_arr;
13039 }
13040
13041 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13042         LDKRevokeAndACK this_ptr_conv;
13043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13044         this_ptr_conv.is_owned = false;
13045         LDKThirtyTwoBytes val_ref;
13046         CHECK(*((uint32_t*)val) == 32);
13047         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13048         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
13049 }
13050
13051 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
13052         LDKRevokeAndACK this_ptr_conv;
13053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13054         this_ptr_conv.is_owned = false;
13055         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13056         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
13057         return ret_arr;
13058 }
13059
13060 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13061         LDKRevokeAndACK this_ptr_conv;
13062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13063         this_ptr_conv.is_owned = false;
13064         LDKThirtyTwoBytes val_ref;
13065         CHECK(*((uint32_t*)val) == 32);
13066         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13067         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
13068 }
13069
13070 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
13071         LDKRevokeAndACK this_ptr_conv;
13072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13073         this_ptr_conv.is_owned = false;
13074         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13075         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13076         return ret_arr;
13077 }
13078
13079 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13080         LDKRevokeAndACK this_ptr_conv;
13081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13082         this_ptr_conv.is_owned = false;
13083         LDKPublicKey val_ref;
13084         CHECK(*((uint32_t*)val) == 33);
13085         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13086         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13087 }
13088
13089 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) {
13090         LDKThirtyTwoBytes channel_id_arg_ref;
13091         CHECK(*((uint32_t*)channel_id_arg) == 32);
13092         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13093         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
13094         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
13095         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
13096         LDKPublicKey next_per_commitment_point_arg_ref;
13097         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
13098         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
13099         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
13100         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13101         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13102         long ret_ref = (long)ret_var.inner;
13103         if (ret_var.is_owned) {
13104                 ret_ref |= 1;
13105         }
13106         return ret_ref;
13107 }
13108
13109 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
13110         LDKRevokeAndACK orig_conv;
13111         orig_conv.inner = (void*)(orig & (~1));
13112         orig_conv.is_owned = false;
13113         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
13114         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13115         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13116         long ret_ref = (long)ret_var.inner;
13117         if (ret_var.is_owned) {
13118                 ret_ref |= 1;
13119         }
13120         return ret_ref;
13121 }
13122
13123 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
13124         LDKUpdateFee this_obj_conv;
13125         this_obj_conv.inner = (void*)(this_obj & (~1));
13126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13127         UpdateFee_free(this_obj_conv);
13128 }
13129
13130 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
13131         LDKUpdateFee this_ptr_conv;
13132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13133         this_ptr_conv.is_owned = false;
13134         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13135         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
13136         return ret_arr;
13137 }
13138
13139 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13140         LDKUpdateFee this_ptr_conv;
13141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13142         this_ptr_conv.is_owned = false;
13143         LDKThirtyTwoBytes val_ref;
13144         CHECK(*((uint32_t*)val) == 32);
13145         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13146         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
13147 }
13148
13149 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
13150         LDKUpdateFee this_ptr_conv;
13151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13152         this_ptr_conv.is_owned = false;
13153         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
13154         return ret_val;
13155 }
13156
13157 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
13158         LDKUpdateFee this_ptr_conv;
13159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13160         this_ptr_conv.is_owned = false;
13161         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
13162 }
13163
13164 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
13165         LDKThirtyTwoBytes channel_id_arg_ref;
13166         CHECK(*((uint32_t*)channel_id_arg) == 32);
13167         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13168         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
13169         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13170         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13171         long ret_ref = (long)ret_var.inner;
13172         if (ret_var.is_owned) {
13173                 ret_ref |= 1;
13174         }
13175         return ret_ref;
13176 }
13177
13178 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
13179         LDKUpdateFee orig_conv;
13180         orig_conv.inner = (void*)(orig & (~1));
13181         orig_conv.is_owned = false;
13182         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
13183         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13184         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13185         long ret_ref = (long)ret_var.inner;
13186         if (ret_var.is_owned) {
13187                 ret_ref |= 1;
13188         }
13189         return ret_ref;
13190 }
13191
13192 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
13193         LDKDataLossProtect this_obj_conv;
13194         this_obj_conv.inner = (void*)(this_obj & (~1));
13195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13196         DataLossProtect_free(this_obj_conv);
13197 }
13198
13199 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
13200         LDKDataLossProtect this_ptr_conv;
13201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13202         this_ptr_conv.is_owned = false;
13203         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13204         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
13205         return ret_arr;
13206 }
13207
13208 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13209         LDKDataLossProtect this_ptr_conv;
13210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13211         this_ptr_conv.is_owned = false;
13212         LDKThirtyTwoBytes val_ref;
13213         CHECK(*((uint32_t*)val) == 32);
13214         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13215         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
13216 }
13217
13218 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
13219         LDKDataLossProtect this_ptr_conv;
13220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13221         this_ptr_conv.is_owned = false;
13222         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13223         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13224         return ret_arr;
13225 }
13226
13227 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13228         LDKDataLossProtect this_ptr_conv;
13229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13230         this_ptr_conv.is_owned = false;
13231         LDKPublicKey val_ref;
13232         CHECK(*((uint32_t*)val) == 33);
13233         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13234         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
13235 }
13236
13237 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
13238         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
13239         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
13240         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
13241         LDKPublicKey my_current_per_commitment_point_arg_ref;
13242         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
13243         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
13244         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
13245         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13246         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13247         long ret_ref = (long)ret_var.inner;
13248         if (ret_var.is_owned) {
13249                 ret_ref |= 1;
13250         }
13251         return ret_ref;
13252 }
13253
13254 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
13255         LDKDataLossProtect orig_conv;
13256         orig_conv.inner = (void*)(orig & (~1));
13257         orig_conv.is_owned = false;
13258         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
13259         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13260         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13261         long ret_ref = (long)ret_var.inner;
13262         if (ret_var.is_owned) {
13263                 ret_ref |= 1;
13264         }
13265         return ret_ref;
13266 }
13267
13268 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
13269         LDKChannelReestablish this_obj_conv;
13270         this_obj_conv.inner = (void*)(this_obj & (~1));
13271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13272         ChannelReestablish_free(this_obj_conv);
13273 }
13274
13275 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
13276         LDKChannelReestablish this_ptr_conv;
13277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13278         this_ptr_conv.is_owned = false;
13279         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13280         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
13281         return ret_arr;
13282 }
13283
13284 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13285         LDKChannelReestablish this_ptr_conv;
13286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13287         this_ptr_conv.is_owned = false;
13288         LDKThirtyTwoBytes val_ref;
13289         CHECK(*((uint32_t*)val) == 32);
13290         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13291         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
13292 }
13293
13294 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
13295         LDKChannelReestablish this_ptr_conv;
13296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13297         this_ptr_conv.is_owned = false;
13298         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
13299         return ret_val;
13300 }
13301
13302 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
13303         LDKChannelReestablish this_ptr_conv;
13304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13305         this_ptr_conv.is_owned = false;
13306         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
13307 }
13308
13309 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
13310         LDKChannelReestablish this_ptr_conv;
13311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13312         this_ptr_conv.is_owned = false;
13313         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
13314         return ret_val;
13315 }
13316
13317 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
13318         LDKChannelReestablish this_ptr_conv;
13319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13320         this_ptr_conv.is_owned = false;
13321         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
13322 }
13323
13324 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
13325         LDKChannelReestablish orig_conv;
13326         orig_conv.inner = (void*)(orig & (~1));
13327         orig_conv.is_owned = false;
13328         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
13329         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13330         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13331         long ret_ref = (long)ret_var.inner;
13332         if (ret_var.is_owned) {
13333                 ret_ref |= 1;
13334         }
13335         return ret_ref;
13336 }
13337
13338 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
13339         LDKAnnouncementSignatures this_obj_conv;
13340         this_obj_conv.inner = (void*)(this_obj & (~1));
13341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13342         AnnouncementSignatures_free(this_obj_conv);
13343 }
13344
13345 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
13346         LDKAnnouncementSignatures this_ptr_conv;
13347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13348         this_ptr_conv.is_owned = false;
13349         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13350         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
13351         return ret_arr;
13352 }
13353
13354 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13355         LDKAnnouncementSignatures this_ptr_conv;
13356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13357         this_ptr_conv.is_owned = false;
13358         LDKThirtyTwoBytes val_ref;
13359         CHECK(*((uint32_t*)val) == 32);
13360         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13361         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
13362 }
13363
13364 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
13365         LDKAnnouncementSignatures this_ptr_conv;
13366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13367         this_ptr_conv.is_owned = false;
13368         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
13369         return ret_val;
13370 }
13371
13372 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
13373         LDKAnnouncementSignatures this_ptr_conv;
13374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13375         this_ptr_conv.is_owned = false;
13376         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
13377 }
13378
13379 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
13380         LDKAnnouncementSignatures this_ptr_conv;
13381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13382         this_ptr_conv.is_owned = false;
13383         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13384         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
13385         return ret_arr;
13386 }
13387
13388 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
13389         LDKAnnouncementSignatures this_ptr_conv;
13390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13391         this_ptr_conv.is_owned = false;
13392         LDKSignature val_ref;
13393         CHECK(*((uint32_t*)val) == 64);
13394         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13395         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
13396 }
13397
13398 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
13399         LDKAnnouncementSignatures this_ptr_conv;
13400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13401         this_ptr_conv.is_owned = false;
13402         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13403         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
13404         return ret_arr;
13405 }
13406
13407 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
13408         LDKAnnouncementSignatures this_ptr_conv;
13409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13410         this_ptr_conv.is_owned = false;
13411         LDKSignature val_ref;
13412         CHECK(*((uint32_t*)val) == 64);
13413         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13414         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
13415 }
13416
13417 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) {
13418         LDKThirtyTwoBytes channel_id_arg_ref;
13419         CHECK(*((uint32_t*)channel_id_arg) == 32);
13420         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13421         LDKSignature node_signature_arg_ref;
13422         CHECK(*((uint32_t*)node_signature_arg) == 64);
13423         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
13424         LDKSignature bitcoin_signature_arg_ref;
13425         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
13426         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
13427         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
13428         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13429         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13430         long ret_ref = (long)ret_var.inner;
13431         if (ret_var.is_owned) {
13432                 ret_ref |= 1;
13433         }
13434         return ret_ref;
13435 }
13436
13437 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
13438         LDKAnnouncementSignatures orig_conv;
13439         orig_conv.inner = (void*)(orig & (~1));
13440         orig_conv.is_owned = false;
13441         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
13442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13444         long ret_ref = (long)ret_var.inner;
13445         if (ret_var.is_owned) {
13446                 ret_ref |= 1;
13447         }
13448         return ret_ref;
13449 }
13450
13451 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
13452         if ((this_ptr & 1) != 0) return;
13453         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
13454         FREE((void*)this_ptr);
13455         NetAddress_free(this_ptr_conv);
13456 }
13457
13458 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
13459         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
13460         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
13461         *ret_copy = NetAddress_clone(orig_conv);
13462         long ret_ref = (long)ret_copy;
13463         return ret_ref;
13464 }
13465
13466 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
13467         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
13468         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
13469         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13470         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13471         CVec_u8Z_free(ret_var);
13472         return ret_arr;
13473 }
13474
13475 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
13476         LDKu8slice ser_ref;
13477         ser_ref.datalen = *((uint32_t*)ser);
13478         ser_ref.data = (int8_t*)(ser + 4);
13479         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13480         *ret_conv = Result_read(ser_ref);
13481         return (long)ret_conv;
13482 }
13483
13484 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
13485         LDKUnsignedNodeAnnouncement this_obj_conv;
13486         this_obj_conv.inner = (void*)(this_obj & (~1));
13487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13488         UnsignedNodeAnnouncement_free(this_obj_conv);
13489 }
13490
13491 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
13492         LDKUnsignedNodeAnnouncement this_ptr_conv;
13493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13494         this_ptr_conv.is_owned = false;
13495         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
13496         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13497         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13498         long ret_ref = (long)ret_var.inner;
13499         if (ret_var.is_owned) {
13500                 ret_ref |= 1;
13501         }
13502         return ret_ref;
13503 }
13504
13505 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
13506         LDKUnsignedNodeAnnouncement this_ptr_conv;
13507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13508         this_ptr_conv.is_owned = false;
13509         LDKNodeFeatures val_conv;
13510         val_conv.inner = (void*)(val & (~1));
13511         val_conv.is_owned = (val & 1) || (val == 0);
13512         val_conv = NodeFeatures_clone(&val_conv);
13513         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
13514 }
13515
13516 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
13517         LDKUnsignedNodeAnnouncement this_ptr_conv;
13518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13519         this_ptr_conv.is_owned = false;
13520         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
13521         return ret_val;
13522 }
13523
13524 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
13525         LDKUnsignedNodeAnnouncement this_ptr_conv;
13526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13527         this_ptr_conv.is_owned = false;
13528         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
13529 }
13530
13531 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
13532         LDKUnsignedNodeAnnouncement this_ptr_conv;
13533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13534         this_ptr_conv.is_owned = false;
13535         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13536         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
13537         return ret_arr;
13538 }
13539
13540 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
13541         LDKUnsignedNodeAnnouncement this_ptr_conv;
13542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13543         this_ptr_conv.is_owned = false;
13544         LDKPublicKey val_ref;
13545         CHECK(*((uint32_t*)val) == 33);
13546         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13547         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
13548 }
13549
13550 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
13551         LDKUnsignedNodeAnnouncement this_ptr_conv;
13552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13553         this_ptr_conv.is_owned = false;
13554         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
13555         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
13556         return ret_arr;
13557 }
13558
13559 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
13560         LDKUnsignedNodeAnnouncement this_ptr_conv;
13561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13562         this_ptr_conv.is_owned = false;
13563         LDKThreeBytes val_ref;
13564         CHECK(*((uint32_t*)val) == 3);
13565         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
13566         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
13567 }
13568
13569 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
13570         LDKUnsignedNodeAnnouncement this_ptr_conv;
13571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13572         this_ptr_conv.is_owned = false;
13573         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13574         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
13575         return ret_arr;
13576 }
13577
13578 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
13579         LDKUnsignedNodeAnnouncement this_ptr_conv;
13580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13581         this_ptr_conv.is_owned = false;
13582         LDKThirtyTwoBytes val_ref;
13583         CHECK(*((uint32_t*)val) == 32);
13584         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13585         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
13586 }
13587
13588 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
13589         LDKUnsignedNodeAnnouncement this_ptr_conv;
13590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13591         this_ptr_conv.is_owned = false;
13592         LDKCVec_NetAddressZ val_constr;
13593         val_constr.datalen = *((uint32_t*)val);
13594         if (val_constr.datalen > 0)
13595                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13596         else
13597                 val_constr.data = NULL;
13598         uint32_t* val_vals = (uint32_t*)(val + 4);
13599         for (size_t m = 0; m < val_constr.datalen; m++) {
13600                 uint32_t val_conv_12 = val_vals[m];
13601                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
13602                 FREE((void*)val_conv_12);
13603                 val_constr.data[m] = val_conv_12_conv;
13604         }
13605         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
13606 }
13607
13608 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
13609         LDKUnsignedNodeAnnouncement orig_conv;
13610         orig_conv.inner = (void*)(orig & (~1));
13611         orig_conv.is_owned = false;
13612         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
13613         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13614         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13615         long ret_ref = (long)ret_var.inner;
13616         if (ret_var.is_owned) {
13617                 ret_ref |= 1;
13618         }
13619         return ret_ref;
13620 }
13621
13622 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
13623         LDKNodeAnnouncement this_obj_conv;
13624         this_obj_conv.inner = (void*)(this_obj & (~1));
13625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13626         NodeAnnouncement_free(this_obj_conv);
13627 }
13628
13629 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
13630         LDKNodeAnnouncement this_ptr_conv;
13631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13632         this_ptr_conv.is_owned = false;
13633         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13634         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
13635         return ret_arr;
13636 }
13637
13638 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
13639         LDKNodeAnnouncement this_ptr_conv;
13640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13641         this_ptr_conv.is_owned = false;
13642         LDKSignature val_ref;
13643         CHECK(*((uint32_t*)val) == 64);
13644         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13645         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
13646 }
13647
13648 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
13649         LDKNodeAnnouncement this_ptr_conv;
13650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13651         this_ptr_conv.is_owned = false;
13652         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
13653         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13654         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13655         long ret_ref = (long)ret_var.inner;
13656         if (ret_var.is_owned) {
13657                 ret_ref |= 1;
13658         }
13659         return ret_ref;
13660 }
13661
13662 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
13663         LDKNodeAnnouncement this_ptr_conv;
13664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13665         this_ptr_conv.is_owned = false;
13666         LDKUnsignedNodeAnnouncement val_conv;
13667         val_conv.inner = (void*)(val & (~1));
13668         val_conv.is_owned = (val & 1) || (val == 0);
13669         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
13670         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
13671 }
13672
13673 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
13674         LDKSignature signature_arg_ref;
13675         CHECK(*((uint32_t*)signature_arg) == 64);
13676         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13677         LDKUnsignedNodeAnnouncement contents_arg_conv;
13678         contents_arg_conv.inner = (void*)(contents_arg & (~1));
13679         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
13680         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
13681         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
13682         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13683         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13684         long ret_ref = (long)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_NodeAnnouncement_clone(uint32_t orig) {
13692         LDKNodeAnnouncement orig_conv;
13693         orig_conv.inner = (void*)(orig & (~1));
13694         orig_conv.is_owned = false;
13695         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
13696         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13697         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13698         long ret_ref = (long)ret_var.inner;
13699         if (ret_var.is_owned) {
13700                 ret_ref |= 1;
13701         }
13702         return ret_ref;
13703 }
13704
13705 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
13706         LDKUnsignedChannelAnnouncement this_obj_conv;
13707         this_obj_conv.inner = (void*)(this_obj & (~1));
13708         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13709         UnsignedChannelAnnouncement_free(this_obj_conv);
13710 }
13711
13712 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
13713         LDKUnsignedChannelAnnouncement this_ptr_conv;
13714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13715         this_ptr_conv.is_owned = false;
13716         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
13717         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13718         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13719         long ret_ref = (long)ret_var.inner;
13720         if (ret_var.is_owned) {
13721                 ret_ref |= 1;
13722         }
13723         return ret_ref;
13724 }
13725
13726 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
13727         LDKUnsignedChannelAnnouncement this_ptr_conv;
13728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13729         this_ptr_conv.is_owned = false;
13730         LDKChannelFeatures val_conv;
13731         val_conv.inner = (void*)(val & (~1));
13732         val_conv.is_owned = (val & 1) || (val == 0);
13733         val_conv = ChannelFeatures_clone(&val_conv);
13734         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
13735 }
13736
13737 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
13738         LDKUnsignedChannelAnnouncement this_ptr_conv;
13739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13740         this_ptr_conv.is_owned = false;
13741         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13742         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
13743         return ret_arr;
13744 }
13745
13746 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
13747         LDKUnsignedChannelAnnouncement this_ptr_conv;
13748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13749         this_ptr_conv.is_owned = false;
13750         LDKThirtyTwoBytes val_ref;
13751         CHECK(*((uint32_t*)val) == 32);
13752         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13753         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
13754 }
13755
13756 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
13757         LDKUnsignedChannelAnnouncement this_ptr_conv;
13758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13759         this_ptr_conv.is_owned = false;
13760         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
13761         return ret_val;
13762 }
13763
13764 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
13765         LDKUnsignedChannelAnnouncement this_ptr_conv;
13766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13767         this_ptr_conv.is_owned = false;
13768         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
13769 }
13770
13771 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
13772         LDKUnsignedChannelAnnouncement this_ptr_conv;
13773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13774         this_ptr_conv.is_owned = false;
13775         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13776         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
13777         return ret_arr;
13778 }
13779
13780 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
13781         LDKUnsignedChannelAnnouncement this_ptr_conv;
13782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13783         this_ptr_conv.is_owned = false;
13784         LDKPublicKey val_ref;
13785         CHECK(*((uint32_t*)val) == 33);
13786         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13787         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
13788 }
13789
13790 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
13791         LDKUnsignedChannelAnnouncement this_ptr_conv;
13792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13793         this_ptr_conv.is_owned = false;
13794         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13795         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
13796         return ret_arr;
13797 }
13798
13799 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
13800         LDKUnsignedChannelAnnouncement this_ptr_conv;
13801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13802         this_ptr_conv.is_owned = false;
13803         LDKPublicKey val_ref;
13804         CHECK(*((uint32_t*)val) == 33);
13805         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13806         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
13807 }
13808
13809 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
13810         LDKUnsignedChannelAnnouncement this_ptr_conv;
13811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13812         this_ptr_conv.is_owned = false;
13813         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13814         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
13815         return ret_arr;
13816 }
13817
13818 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
13819         LDKUnsignedChannelAnnouncement this_ptr_conv;
13820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13821         this_ptr_conv.is_owned = false;
13822         LDKPublicKey val_ref;
13823         CHECK(*((uint32_t*)val) == 33);
13824         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13825         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
13826 }
13827
13828 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
13829         LDKUnsignedChannelAnnouncement this_ptr_conv;
13830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13831         this_ptr_conv.is_owned = false;
13832         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13833         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
13834         return ret_arr;
13835 }
13836
13837 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
13838         LDKUnsignedChannelAnnouncement this_ptr_conv;
13839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13840         this_ptr_conv.is_owned = false;
13841         LDKPublicKey val_ref;
13842         CHECK(*((uint32_t*)val) == 33);
13843         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13844         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
13845 }
13846
13847 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
13848         LDKUnsignedChannelAnnouncement orig_conv;
13849         orig_conv.inner = (void*)(orig & (~1));
13850         orig_conv.is_owned = false;
13851         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
13852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13854         long ret_ref = (long)ret_var.inner;
13855         if (ret_var.is_owned) {
13856                 ret_ref |= 1;
13857         }
13858         return ret_ref;
13859 }
13860
13861 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
13862         LDKChannelAnnouncement this_obj_conv;
13863         this_obj_conv.inner = (void*)(this_obj & (~1));
13864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13865         ChannelAnnouncement_free(this_obj_conv);
13866 }
13867
13868 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
13869         LDKChannelAnnouncement this_ptr_conv;
13870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13871         this_ptr_conv.is_owned = false;
13872         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13873         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
13874         return ret_arr;
13875 }
13876
13877 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
13878         LDKChannelAnnouncement this_ptr_conv;
13879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13880         this_ptr_conv.is_owned = false;
13881         LDKSignature val_ref;
13882         CHECK(*((uint32_t*)val) == 64);
13883         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13884         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
13885 }
13886
13887 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
13888         LDKChannelAnnouncement this_ptr_conv;
13889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13890         this_ptr_conv.is_owned = false;
13891         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13892         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
13893         return ret_arr;
13894 }
13895
13896 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
13897         LDKChannelAnnouncement this_ptr_conv;
13898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13899         this_ptr_conv.is_owned = false;
13900         LDKSignature val_ref;
13901         CHECK(*((uint32_t*)val) == 64);
13902         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13903         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
13904 }
13905
13906 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
13907         LDKChannelAnnouncement this_ptr_conv;
13908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13909         this_ptr_conv.is_owned = false;
13910         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13911         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
13912         return ret_arr;
13913 }
13914
13915 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
13916         LDKChannelAnnouncement this_ptr_conv;
13917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13918         this_ptr_conv.is_owned = false;
13919         LDKSignature val_ref;
13920         CHECK(*((uint32_t*)val) == 64);
13921         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13922         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
13923 }
13924
13925 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
13926         LDKChannelAnnouncement this_ptr_conv;
13927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13928         this_ptr_conv.is_owned = false;
13929         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13930         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
13931         return ret_arr;
13932 }
13933
13934 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
13935         LDKChannelAnnouncement this_ptr_conv;
13936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13937         this_ptr_conv.is_owned = false;
13938         LDKSignature val_ref;
13939         CHECK(*((uint32_t*)val) == 64);
13940         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13941         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
13942 }
13943
13944 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
13945         LDKChannelAnnouncement this_ptr_conv;
13946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13947         this_ptr_conv.is_owned = false;
13948         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
13949         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13950         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13951         long ret_ref = (long)ret_var.inner;
13952         if (ret_var.is_owned) {
13953                 ret_ref |= 1;
13954         }
13955         return ret_ref;
13956 }
13957
13958 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
13959         LDKChannelAnnouncement this_ptr_conv;
13960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13961         this_ptr_conv.is_owned = false;
13962         LDKUnsignedChannelAnnouncement val_conv;
13963         val_conv.inner = (void*)(val & (~1));
13964         val_conv.is_owned = (val & 1) || (val == 0);
13965         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
13966         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
13967 }
13968
13969 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) {
13970         LDKSignature node_signature_1_arg_ref;
13971         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
13972         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
13973         LDKSignature node_signature_2_arg_ref;
13974         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
13975         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
13976         LDKSignature bitcoin_signature_1_arg_ref;
13977         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
13978         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
13979         LDKSignature bitcoin_signature_2_arg_ref;
13980         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
13981         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
13982         LDKUnsignedChannelAnnouncement contents_arg_conv;
13983         contents_arg_conv.inner = (void*)(contents_arg & (~1));
13984         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
13985         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
13986         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);
13987         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13988         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13989         long ret_ref = (long)ret_var.inner;
13990         if (ret_var.is_owned) {
13991                 ret_ref |= 1;
13992         }
13993         return ret_ref;
13994 }
13995
13996 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
13997         LDKChannelAnnouncement orig_conv;
13998         orig_conv.inner = (void*)(orig & (~1));
13999         orig_conv.is_owned = false;
14000         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
14001         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14002         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14003         long ret_ref = (long)ret_var.inner;
14004         if (ret_var.is_owned) {
14005                 ret_ref |= 1;
14006         }
14007         return ret_ref;
14008 }
14009
14010 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
14011         LDKUnsignedChannelUpdate this_obj_conv;
14012         this_obj_conv.inner = (void*)(this_obj & (~1));
14013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14014         UnsignedChannelUpdate_free(this_obj_conv);
14015 }
14016
14017 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
14018         LDKUnsignedChannelUpdate this_ptr_conv;
14019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14020         this_ptr_conv.is_owned = false;
14021         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14022         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
14023         return ret_arr;
14024 }
14025
14026 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14027         LDKUnsignedChannelUpdate this_ptr_conv;
14028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14029         this_ptr_conv.is_owned = false;
14030         LDKThirtyTwoBytes val_ref;
14031         CHECK(*((uint32_t*)val) == 32);
14032         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14033         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
14034 }
14035
14036 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
14037         LDKUnsignedChannelUpdate this_ptr_conv;
14038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14039         this_ptr_conv.is_owned = false;
14040         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
14041         return ret_val;
14042 }
14043
14044 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14045         LDKUnsignedChannelUpdate this_ptr_conv;
14046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14047         this_ptr_conv.is_owned = false;
14048         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
14049 }
14050
14051 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
14052         LDKUnsignedChannelUpdate this_ptr_conv;
14053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14054         this_ptr_conv.is_owned = false;
14055         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
14056         return ret_val;
14057 }
14058
14059 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
14060         LDKUnsignedChannelUpdate this_ptr_conv;
14061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14062         this_ptr_conv.is_owned = false;
14063         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
14064 }
14065
14066 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
14067         LDKUnsignedChannelUpdate this_ptr_conv;
14068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14069         this_ptr_conv.is_owned = false;
14070         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
14071         return ret_val;
14072 }
14073
14074 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
14075         LDKUnsignedChannelUpdate this_ptr_conv;
14076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14077         this_ptr_conv.is_owned = false;
14078         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
14079 }
14080
14081 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
14082         LDKUnsignedChannelUpdate this_ptr_conv;
14083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14084         this_ptr_conv.is_owned = false;
14085         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
14086         return ret_val;
14087 }
14088
14089 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14090         LDKUnsignedChannelUpdate this_ptr_conv;
14091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14092         this_ptr_conv.is_owned = false;
14093         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
14094 }
14095
14096 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
14097         LDKUnsignedChannelUpdate this_ptr_conv;
14098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14099         this_ptr_conv.is_owned = false;
14100         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
14101         return ret_val;
14102 }
14103
14104 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14105         LDKUnsignedChannelUpdate this_ptr_conv;
14106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14107         this_ptr_conv.is_owned = false;
14108         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
14109 }
14110
14111 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
14112         LDKUnsignedChannelUpdate this_ptr_conv;
14113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14114         this_ptr_conv.is_owned = false;
14115         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
14116         return ret_val;
14117 }
14118
14119 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
14120         LDKUnsignedChannelUpdate this_ptr_conv;
14121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14122         this_ptr_conv.is_owned = false;
14123         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
14124 }
14125
14126 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
14127         LDKUnsignedChannelUpdate this_ptr_conv;
14128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14129         this_ptr_conv.is_owned = false;
14130         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
14131         return ret_val;
14132 }
14133
14134 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14135         LDKUnsignedChannelUpdate this_ptr_conv;
14136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14137         this_ptr_conv.is_owned = false;
14138         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
14139 }
14140
14141 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
14142         LDKUnsignedChannelUpdate orig_conv;
14143         orig_conv.inner = (void*)(orig & (~1));
14144         orig_conv.is_owned = false;
14145         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
14146         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14147         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14148         long ret_ref = (long)ret_var.inner;
14149         if (ret_var.is_owned) {
14150                 ret_ref |= 1;
14151         }
14152         return ret_ref;
14153 }
14154
14155 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
14156         LDKChannelUpdate this_obj_conv;
14157         this_obj_conv.inner = (void*)(this_obj & (~1));
14158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14159         ChannelUpdate_free(this_obj_conv);
14160 }
14161
14162 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
14163         LDKChannelUpdate this_ptr_conv;
14164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14165         this_ptr_conv.is_owned = false;
14166         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14167         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
14168         return ret_arr;
14169 }
14170
14171 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
14172         LDKChannelUpdate this_ptr_conv;
14173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14174         this_ptr_conv.is_owned = false;
14175         LDKSignature val_ref;
14176         CHECK(*((uint32_t*)val) == 64);
14177         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14178         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
14179 }
14180
14181 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
14182         LDKChannelUpdate this_ptr_conv;
14183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14184         this_ptr_conv.is_owned = false;
14185         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
14186         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14187         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14188         long ret_ref = (long)ret_var.inner;
14189         if (ret_var.is_owned) {
14190                 ret_ref |= 1;
14191         }
14192         return ret_ref;
14193 }
14194
14195 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
14196         LDKChannelUpdate this_ptr_conv;
14197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14198         this_ptr_conv.is_owned = false;
14199         LDKUnsignedChannelUpdate val_conv;
14200         val_conv.inner = (void*)(val & (~1));
14201         val_conv.is_owned = (val & 1) || (val == 0);
14202         val_conv = UnsignedChannelUpdate_clone(&val_conv);
14203         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
14204 }
14205
14206 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
14207         LDKSignature signature_arg_ref;
14208         CHECK(*((uint32_t*)signature_arg) == 64);
14209         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14210         LDKUnsignedChannelUpdate contents_arg_conv;
14211         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14212         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14213         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
14214         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
14215         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14216         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14217         long ret_ref = (long)ret_var.inner;
14218         if (ret_var.is_owned) {
14219                 ret_ref |= 1;
14220         }
14221         return ret_ref;
14222 }
14223
14224 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
14225         LDKChannelUpdate orig_conv;
14226         orig_conv.inner = (void*)(orig & (~1));
14227         orig_conv.is_owned = false;
14228         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
14229         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14230         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14231         long ret_ref = (long)ret_var.inner;
14232         if (ret_var.is_owned) {
14233                 ret_ref |= 1;
14234         }
14235         return ret_ref;
14236 }
14237
14238 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
14239         LDKQueryChannelRange this_obj_conv;
14240         this_obj_conv.inner = (void*)(this_obj & (~1));
14241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14242         QueryChannelRange_free(this_obj_conv);
14243 }
14244
14245 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
14246         LDKQueryChannelRange this_ptr_conv;
14247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14248         this_ptr_conv.is_owned = false;
14249         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14250         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
14251         return ret_arr;
14252 }
14253
14254 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14255         LDKQueryChannelRange this_ptr_conv;
14256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14257         this_ptr_conv.is_owned = false;
14258         LDKThirtyTwoBytes val_ref;
14259         CHECK(*((uint32_t*)val) == 32);
14260         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14261         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14262 }
14263
14264 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
14265         LDKQueryChannelRange this_ptr_conv;
14266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14267         this_ptr_conv.is_owned = false;
14268         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
14269         return ret_val;
14270 }
14271
14272 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14273         LDKQueryChannelRange this_ptr_conv;
14274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14275         this_ptr_conv.is_owned = false;
14276         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
14277 }
14278
14279 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14280         LDKQueryChannelRange this_ptr_conv;
14281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14282         this_ptr_conv.is_owned = false;
14283         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
14284         return ret_val;
14285 }
14286
14287 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14288         LDKQueryChannelRange this_ptr_conv;
14289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14290         this_ptr_conv.is_owned = false;
14291         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14292 }
14293
14294 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
14295         LDKThirtyTwoBytes chain_hash_arg_ref;
14296         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14297         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14298         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
14299         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14300         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14301         long ret_ref = (long)ret_var.inner;
14302         if (ret_var.is_owned) {
14303                 ret_ref |= 1;
14304         }
14305         return ret_ref;
14306 }
14307
14308 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
14309         LDKQueryChannelRange orig_conv;
14310         orig_conv.inner = (void*)(orig & (~1));
14311         orig_conv.is_owned = false;
14312         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
14313         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14314         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14315         long ret_ref = (long)ret_var.inner;
14316         if (ret_var.is_owned) {
14317                 ret_ref |= 1;
14318         }
14319         return ret_ref;
14320 }
14321
14322 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
14323         LDKReplyChannelRange this_obj_conv;
14324         this_obj_conv.inner = (void*)(this_obj & (~1));
14325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14326         ReplyChannelRange_free(this_obj_conv);
14327 }
14328
14329 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
14330         LDKReplyChannelRange this_ptr_conv;
14331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14332         this_ptr_conv.is_owned = false;
14333         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14334         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
14335         return ret_arr;
14336 }
14337
14338 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14339         LDKReplyChannelRange this_ptr_conv;
14340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14341         this_ptr_conv.is_owned = false;
14342         LDKThirtyTwoBytes val_ref;
14343         CHECK(*((uint32_t*)val) == 32);
14344         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14345         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14346 }
14347
14348 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
14349         LDKReplyChannelRange this_ptr_conv;
14350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14351         this_ptr_conv.is_owned = false;
14352         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
14353         return ret_val;
14354 }
14355
14356 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14357         LDKReplyChannelRange this_ptr_conv;
14358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14359         this_ptr_conv.is_owned = false;
14360         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
14361 }
14362
14363 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14364         LDKReplyChannelRange this_ptr_conv;
14365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14366         this_ptr_conv.is_owned = false;
14367         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
14368         return ret_val;
14369 }
14370
14371 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14372         LDKReplyChannelRange this_ptr_conv;
14373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14374         this_ptr_conv.is_owned = false;
14375         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14376 }
14377
14378 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
14379         LDKReplyChannelRange this_ptr_conv;
14380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14381         this_ptr_conv.is_owned = false;
14382         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
14383         return ret_val;
14384 }
14385
14386 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
14387         LDKReplyChannelRange this_ptr_conv;
14388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14389         this_ptr_conv.is_owned = false;
14390         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
14391 }
14392
14393 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14394         LDKReplyChannelRange this_ptr_conv;
14395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14396         this_ptr_conv.is_owned = false;
14397         LDKCVec_u64Z val_constr;
14398         val_constr.datalen = *((uint32_t*)val);
14399         if (val_constr.datalen > 0)
14400                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14401         else
14402                 val_constr.data = NULL;
14403         int64_t* val_vals = (int64_t*)(val + 4);
14404         for (size_t i = 0; i < val_constr.datalen; i++) {
14405                 int64_t val_conv_8 = val_vals[i];
14406                 val_constr.data[i] = val_conv_8;
14407         }
14408         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
14409 }
14410
14411 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) {
14412         LDKThirtyTwoBytes chain_hash_arg_ref;
14413         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14414         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14415         LDKCVec_u64Z short_channel_ids_arg_constr;
14416         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14417         if (short_channel_ids_arg_constr.datalen > 0)
14418                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14419         else
14420                 short_channel_ids_arg_constr.data = NULL;
14421         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14422         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14423                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14424                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14425         }
14426         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
14427         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14428         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14429         long ret_ref = (long)ret_var.inner;
14430         if (ret_var.is_owned) {
14431                 ret_ref |= 1;
14432         }
14433         return ret_ref;
14434 }
14435
14436 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
14437         LDKReplyChannelRange orig_conv;
14438         orig_conv.inner = (void*)(orig & (~1));
14439         orig_conv.is_owned = false;
14440         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
14441         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14442         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14443         long ret_ref = (long)ret_var.inner;
14444         if (ret_var.is_owned) {
14445                 ret_ref |= 1;
14446         }
14447         return ret_ref;
14448 }
14449
14450 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
14451         LDKQueryShortChannelIds this_obj_conv;
14452         this_obj_conv.inner = (void*)(this_obj & (~1));
14453         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14454         QueryShortChannelIds_free(this_obj_conv);
14455 }
14456
14457 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
14458         LDKQueryShortChannelIds this_ptr_conv;
14459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14460         this_ptr_conv.is_owned = false;
14461         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14462         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
14463         return ret_arr;
14464 }
14465
14466 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14467         LDKQueryShortChannelIds this_ptr_conv;
14468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14469         this_ptr_conv.is_owned = false;
14470         LDKThirtyTwoBytes val_ref;
14471         CHECK(*((uint32_t*)val) == 32);
14472         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14473         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
14474 }
14475
14476 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14477         LDKQueryShortChannelIds this_ptr_conv;
14478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14479         this_ptr_conv.is_owned = false;
14480         LDKCVec_u64Z val_constr;
14481         val_constr.datalen = *((uint32_t*)val);
14482         if (val_constr.datalen > 0)
14483                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14484         else
14485                 val_constr.data = NULL;
14486         int64_t* val_vals = (int64_t*)(val + 4);
14487         for (size_t i = 0; i < val_constr.datalen; i++) {
14488                 int64_t val_conv_8 = val_vals[i];
14489                 val_constr.data[i] = val_conv_8;
14490         }
14491         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
14492 }
14493
14494 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
14495         LDKThirtyTwoBytes chain_hash_arg_ref;
14496         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14497         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14498         LDKCVec_u64Z short_channel_ids_arg_constr;
14499         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14500         if (short_channel_ids_arg_constr.datalen > 0)
14501                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14502         else
14503                 short_channel_ids_arg_constr.data = NULL;
14504         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14505         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14506                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14507                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14508         }
14509         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
14510         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14511         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14512         long ret_ref = (long)ret_var.inner;
14513         if (ret_var.is_owned) {
14514                 ret_ref |= 1;
14515         }
14516         return ret_ref;
14517 }
14518
14519 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
14520         LDKQueryShortChannelIds orig_conv;
14521         orig_conv.inner = (void*)(orig & (~1));
14522         orig_conv.is_owned = false;
14523         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
14524         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14525         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14526         long ret_ref = (long)ret_var.inner;
14527         if (ret_var.is_owned) {
14528                 ret_ref |= 1;
14529         }
14530         return ret_ref;
14531 }
14532
14533 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
14534         LDKReplyShortChannelIdsEnd this_obj_conv;
14535         this_obj_conv.inner = (void*)(this_obj & (~1));
14536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14537         ReplyShortChannelIdsEnd_free(this_obj_conv);
14538 }
14539
14540 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
14541         LDKReplyShortChannelIdsEnd this_ptr_conv;
14542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14543         this_ptr_conv.is_owned = false;
14544         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14545         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
14546         return ret_arr;
14547 }
14548
14549 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14550         LDKReplyShortChannelIdsEnd this_ptr_conv;
14551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14552         this_ptr_conv.is_owned = false;
14553         LDKThirtyTwoBytes val_ref;
14554         CHECK(*((uint32_t*)val) == 32);
14555         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14556         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
14557 }
14558
14559 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
14560         LDKReplyShortChannelIdsEnd this_ptr_conv;
14561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14562         this_ptr_conv.is_owned = false;
14563         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
14564         return ret_val;
14565 }
14566
14567 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
14568         LDKReplyShortChannelIdsEnd this_ptr_conv;
14569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14570         this_ptr_conv.is_owned = false;
14571         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
14572 }
14573
14574 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
14575         LDKThirtyTwoBytes chain_hash_arg_ref;
14576         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14577         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14578         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
14579         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14580         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14581         long ret_ref = (long)ret_var.inner;
14582         if (ret_var.is_owned) {
14583                 ret_ref |= 1;
14584         }
14585         return ret_ref;
14586 }
14587
14588 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
14589         LDKReplyShortChannelIdsEnd orig_conv;
14590         orig_conv.inner = (void*)(orig & (~1));
14591         orig_conv.is_owned = false;
14592         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
14593         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14594         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14595         long ret_ref = (long)ret_var.inner;
14596         if (ret_var.is_owned) {
14597                 ret_ref |= 1;
14598         }
14599         return ret_ref;
14600 }
14601
14602 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
14603         LDKGossipTimestampFilter this_obj_conv;
14604         this_obj_conv.inner = (void*)(this_obj & (~1));
14605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14606         GossipTimestampFilter_free(this_obj_conv);
14607 }
14608
14609 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
14610         LDKGossipTimestampFilter this_ptr_conv;
14611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14612         this_ptr_conv.is_owned = false;
14613         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14614         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
14615         return ret_arr;
14616 }
14617
14618 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14619         LDKGossipTimestampFilter this_ptr_conv;
14620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14621         this_ptr_conv.is_owned = false;
14622         LDKThirtyTwoBytes val_ref;
14623         CHECK(*((uint32_t*)val) == 32);
14624         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14625         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
14626 }
14627
14628 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
14629         LDKGossipTimestampFilter this_ptr_conv;
14630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14631         this_ptr_conv.is_owned = false;
14632         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
14633         return ret_val;
14634 }
14635
14636 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
14637         LDKGossipTimestampFilter this_ptr_conv;
14638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14639         this_ptr_conv.is_owned = false;
14640         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
14641 }
14642
14643 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
14644         LDKGossipTimestampFilter this_ptr_conv;
14645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14646         this_ptr_conv.is_owned = false;
14647         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
14648         return ret_val;
14649 }
14650
14651 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
14652         LDKGossipTimestampFilter this_ptr_conv;
14653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14654         this_ptr_conv.is_owned = false;
14655         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
14656 }
14657
14658 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
14659         LDKThirtyTwoBytes chain_hash_arg_ref;
14660         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14661         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14662         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
14663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14665         long ret_ref = (long)ret_var.inner;
14666         if (ret_var.is_owned) {
14667                 ret_ref |= 1;
14668         }
14669         return ret_ref;
14670 }
14671
14672 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
14673         LDKGossipTimestampFilter orig_conv;
14674         orig_conv.inner = (void*)(orig & (~1));
14675         orig_conv.is_owned = false;
14676         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
14677         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14678         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14679         long ret_ref = (long)ret_var.inner;
14680         if (ret_var.is_owned) {
14681                 ret_ref |= 1;
14682         }
14683         return ret_ref;
14684 }
14685
14686 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
14687         if ((this_ptr & 1) != 0) return;
14688         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
14689         FREE((void*)this_ptr);
14690         ErrorAction_free(this_ptr_conv);
14691 }
14692
14693 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
14694         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
14695         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14696         *ret_copy = ErrorAction_clone(orig_conv);
14697         long ret_ref = (long)ret_copy;
14698         return ret_ref;
14699 }
14700
14701 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
14702         LDKLightningError this_obj_conv;
14703         this_obj_conv.inner = (void*)(this_obj & (~1));
14704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14705         LightningError_free(this_obj_conv);
14706 }
14707
14708 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
14709         LDKLightningError this_ptr_conv;
14710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14711         this_ptr_conv.is_owned = false;
14712         LDKStr _str = LightningError_get_err(&this_ptr_conv);
14713         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
14714         return _conv;
14715 }
14716
14717 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
14718         LDKLightningError this_ptr_conv;
14719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14720         this_ptr_conv.is_owned = false;
14721         LDKCVec_u8Z val_ref;
14722         val_ref.datalen = *((uint32_t*)val);
14723         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14724         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14725         LightningError_set_err(&this_ptr_conv, val_ref);
14726 }
14727
14728 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
14729         LDKLightningError this_ptr_conv;
14730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14731         this_ptr_conv.is_owned = false;
14732         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14733         *ret_copy = LightningError_get_action(&this_ptr_conv);
14734         long ret_ref = (long)ret_copy;
14735         return ret_ref;
14736 }
14737
14738 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
14739         LDKLightningError this_ptr_conv;
14740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14741         this_ptr_conv.is_owned = false;
14742         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
14743         FREE((void*)val);
14744         LightningError_set_action(&this_ptr_conv, val_conv);
14745 }
14746
14747 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
14748         LDKCVec_u8Z err_arg_ref;
14749         err_arg_ref.datalen = *((uint32_t*)err_arg);
14750         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14751         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
14752         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
14753         FREE((void*)action_arg);
14754         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
14755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14757         long ret_ref = (long)ret_var.inner;
14758         if (ret_var.is_owned) {
14759                 ret_ref |= 1;
14760         }
14761         return ret_ref;
14762 }
14763
14764 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
14765         LDKLightningError orig_conv;
14766         orig_conv.inner = (void*)(orig & (~1));
14767         orig_conv.is_owned = false;
14768         LDKLightningError ret_var = LightningError_clone(&orig_conv);
14769         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14770         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14771         long ret_ref = (long)ret_var.inner;
14772         if (ret_var.is_owned) {
14773                 ret_ref |= 1;
14774         }
14775         return ret_ref;
14776 }
14777
14778 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
14779         LDKCommitmentUpdate this_obj_conv;
14780         this_obj_conv.inner = (void*)(this_obj & (~1));
14781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14782         CommitmentUpdate_free(this_obj_conv);
14783 }
14784
14785 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
14786         LDKCommitmentUpdate this_ptr_conv;
14787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14788         this_ptr_conv.is_owned = false;
14789         LDKCVec_UpdateAddHTLCZ val_constr;
14790         val_constr.datalen = *((uint32_t*)val);
14791         if (val_constr.datalen > 0)
14792                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14793         else
14794                 val_constr.data = NULL;
14795         uint32_t* val_vals = (uint32_t*)(val + 4);
14796         for (size_t p = 0; p < val_constr.datalen; p++) {
14797                 uint32_t val_conv_15 = val_vals[p];
14798                 LDKUpdateAddHTLC val_conv_15_conv;
14799                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
14800                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
14801                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
14802                 val_constr.data[p] = val_conv_15_conv;
14803         }
14804         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
14805 }
14806
14807 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
14808         LDKCommitmentUpdate this_ptr_conv;
14809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14810         this_ptr_conv.is_owned = false;
14811         LDKCVec_UpdateFulfillHTLCZ val_constr;
14812         val_constr.datalen = *((uint32_t*)val);
14813         if (val_constr.datalen > 0)
14814                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14815         else
14816                 val_constr.data = NULL;
14817         uint32_t* val_vals = (uint32_t*)(val + 4);
14818         for (size_t t = 0; t < val_constr.datalen; t++) {
14819                 uint32_t val_conv_19 = val_vals[t];
14820                 LDKUpdateFulfillHTLC val_conv_19_conv;
14821                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
14822                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
14823                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
14824                 val_constr.data[t] = val_conv_19_conv;
14825         }
14826         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
14827 }
14828
14829 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
14830         LDKCommitmentUpdate this_ptr_conv;
14831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14832         this_ptr_conv.is_owned = false;
14833         LDKCVec_UpdateFailHTLCZ val_constr;
14834         val_constr.datalen = *((uint32_t*)val);
14835         if (val_constr.datalen > 0)
14836                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14837         else
14838                 val_constr.data = NULL;
14839         uint32_t* val_vals = (uint32_t*)(val + 4);
14840         for (size_t q = 0; q < val_constr.datalen; q++) {
14841                 uint32_t val_conv_16 = val_vals[q];
14842                 LDKUpdateFailHTLC val_conv_16_conv;
14843                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
14844                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
14845                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
14846                 val_constr.data[q] = val_conv_16_conv;
14847         }
14848         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
14849 }
14850
14851 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
14852         LDKCommitmentUpdate this_ptr_conv;
14853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14854         this_ptr_conv.is_owned = false;
14855         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
14856         val_constr.datalen = *((uint32_t*)val);
14857         if (val_constr.datalen > 0)
14858                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14859         else
14860                 val_constr.data = NULL;
14861         uint32_t* val_vals = (uint32_t*)(val + 4);
14862         for (size_t z = 0; z < val_constr.datalen; z++) {
14863                 uint32_t val_conv_25 = val_vals[z];
14864                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
14865                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
14866                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
14867                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
14868                 val_constr.data[z] = val_conv_25_conv;
14869         }
14870         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
14871 }
14872
14873 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
14874         LDKCommitmentUpdate this_ptr_conv;
14875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14876         this_ptr_conv.is_owned = false;
14877         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
14878         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14879         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14880         long ret_ref = (long)ret_var.inner;
14881         if (ret_var.is_owned) {
14882                 ret_ref |= 1;
14883         }
14884         return ret_ref;
14885 }
14886
14887 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
14888         LDKCommitmentUpdate this_ptr_conv;
14889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14890         this_ptr_conv.is_owned = false;
14891         LDKUpdateFee val_conv;
14892         val_conv.inner = (void*)(val & (~1));
14893         val_conv.is_owned = (val & 1) || (val == 0);
14894         val_conv = UpdateFee_clone(&val_conv);
14895         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
14896 }
14897
14898 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
14899         LDKCommitmentUpdate this_ptr_conv;
14900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14901         this_ptr_conv.is_owned = false;
14902         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
14903         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14904         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14905         long ret_ref = (long)ret_var.inner;
14906         if (ret_var.is_owned) {
14907                 ret_ref |= 1;
14908         }
14909         return ret_ref;
14910 }
14911
14912 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
14913         LDKCommitmentUpdate this_ptr_conv;
14914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14915         this_ptr_conv.is_owned = false;
14916         LDKCommitmentSigned val_conv;
14917         val_conv.inner = (void*)(val & (~1));
14918         val_conv.is_owned = (val & 1) || (val == 0);
14919         val_conv = CommitmentSigned_clone(&val_conv);
14920         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
14921 }
14922
14923 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) {
14924         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
14925         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
14926         if (update_add_htlcs_arg_constr.datalen > 0)
14927                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14928         else
14929                 update_add_htlcs_arg_constr.data = NULL;
14930         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
14931         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
14932                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
14933                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
14934                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
14935                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
14936                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
14937                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
14938         }
14939         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
14940         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
14941         if (update_fulfill_htlcs_arg_constr.datalen > 0)
14942                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14943         else
14944                 update_fulfill_htlcs_arg_constr.data = NULL;
14945         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
14946         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
14947                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
14948                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
14949                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
14950                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
14951                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
14952                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
14953         }
14954         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
14955         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
14956         if (update_fail_htlcs_arg_constr.datalen > 0)
14957                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14958         else
14959                 update_fail_htlcs_arg_constr.data = NULL;
14960         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
14961         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
14962                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
14963                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
14964                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
14965                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
14966                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
14967                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
14968         }
14969         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
14970         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
14971         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
14972                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14973         else
14974                 update_fail_malformed_htlcs_arg_constr.data = NULL;
14975         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
14976         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
14977                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
14978                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
14979                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
14980                 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);
14981                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
14982                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
14983         }
14984         LDKUpdateFee update_fee_arg_conv;
14985         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
14986         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
14987         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
14988         LDKCommitmentSigned commitment_signed_arg_conv;
14989         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
14990         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
14991         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
14992         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);
14993         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14994         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14995         long ret_ref = (long)ret_var.inner;
14996         if (ret_var.is_owned) {
14997                 ret_ref |= 1;
14998         }
14999         return ret_ref;
15000 }
15001
15002 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
15003         LDKCommitmentUpdate orig_conv;
15004         orig_conv.inner = (void*)(orig & (~1));
15005         orig_conv.is_owned = false;
15006         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
15007         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15008         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15009         long ret_ref = (long)ret_var.inner;
15010         if (ret_var.is_owned) {
15011                 ret_ref |= 1;
15012         }
15013         return ret_ref;
15014 }
15015
15016 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
15017         if ((this_ptr & 1) != 0) return;
15018         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
15019         FREE((void*)this_ptr);
15020         HTLCFailChannelUpdate_free(this_ptr_conv);
15021 }
15022
15023 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
15024         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
15025         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
15026         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
15027         long ret_ref = (long)ret_copy;
15028         return ret_ref;
15029 }
15030
15031 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
15032         if ((this_ptr & 1) != 0) return;
15033         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
15034         FREE((void*)this_ptr);
15035         ChannelMessageHandler_free(this_ptr_conv);
15036 }
15037
15038 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
15039         if ((this_ptr & 1) != 0) return;
15040         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
15041         FREE((void*)this_ptr);
15042         RoutingMessageHandler_free(this_ptr_conv);
15043 }
15044
15045 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
15046         LDKAcceptChannel obj_conv;
15047         obj_conv.inner = (void*)(obj & (~1));
15048         obj_conv.is_owned = false;
15049         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
15050         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15051         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15052         CVec_u8Z_free(ret_var);
15053         return ret_arr;
15054 }
15055
15056 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
15057         LDKu8slice ser_ref;
15058         ser_ref.datalen = *((uint32_t*)ser);
15059         ser_ref.data = (int8_t*)(ser + 4);
15060         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15061         *ret_conv = AcceptChannel_read(ser_ref);
15062         return (long)ret_conv;
15063 }
15064
15065 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
15066         LDKAnnouncementSignatures obj_conv;
15067         obj_conv.inner = (void*)(obj & (~1));
15068         obj_conv.is_owned = false;
15069         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
15070         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15071         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15072         CVec_u8Z_free(ret_var);
15073         return ret_arr;
15074 }
15075
15076 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
15077         LDKu8slice ser_ref;
15078         ser_ref.datalen = *((uint32_t*)ser);
15079         ser_ref.data = (int8_t*)(ser + 4);
15080         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15081         *ret_conv = AnnouncementSignatures_read(ser_ref);
15082         return (long)ret_conv;
15083 }
15084
15085 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
15086         LDKChannelReestablish obj_conv;
15087         obj_conv.inner = (void*)(obj & (~1));
15088         obj_conv.is_owned = false;
15089         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
15090         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15091         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15092         CVec_u8Z_free(ret_var);
15093         return ret_arr;
15094 }
15095
15096 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
15097         LDKu8slice ser_ref;
15098         ser_ref.datalen = *((uint32_t*)ser);
15099         ser_ref.data = (int8_t*)(ser + 4);
15100         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15101         *ret_conv = ChannelReestablish_read(ser_ref);
15102         return (long)ret_conv;
15103 }
15104
15105 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
15106         LDKClosingSigned obj_conv;
15107         obj_conv.inner = (void*)(obj & (~1));
15108         obj_conv.is_owned = false;
15109         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
15110         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15111         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15112         CVec_u8Z_free(ret_var);
15113         return ret_arr;
15114 }
15115
15116 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
15117         LDKu8slice ser_ref;
15118         ser_ref.datalen = *((uint32_t*)ser);
15119         ser_ref.data = (int8_t*)(ser + 4);
15120         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15121         *ret_conv = ClosingSigned_read(ser_ref);
15122         return (long)ret_conv;
15123 }
15124
15125 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
15126         LDKCommitmentSigned obj_conv;
15127         obj_conv.inner = (void*)(obj & (~1));
15128         obj_conv.is_owned = false;
15129         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
15130         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15131         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15132         CVec_u8Z_free(ret_var);
15133         return ret_arr;
15134 }
15135
15136 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
15137         LDKu8slice ser_ref;
15138         ser_ref.datalen = *((uint32_t*)ser);
15139         ser_ref.data = (int8_t*)(ser + 4);
15140         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15141         *ret_conv = CommitmentSigned_read(ser_ref);
15142         return (long)ret_conv;
15143 }
15144
15145 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
15146         LDKFundingCreated obj_conv;
15147         obj_conv.inner = (void*)(obj & (~1));
15148         obj_conv.is_owned = false;
15149         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
15150         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15151         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15152         CVec_u8Z_free(ret_var);
15153         return ret_arr;
15154 }
15155
15156 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
15157         LDKu8slice ser_ref;
15158         ser_ref.datalen = *((uint32_t*)ser);
15159         ser_ref.data = (int8_t*)(ser + 4);
15160         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15161         *ret_conv = FundingCreated_read(ser_ref);
15162         return (long)ret_conv;
15163 }
15164
15165 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
15166         LDKFundingSigned obj_conv;
15167         obj_conv.inner = (void*)(obj & (~1));
15168         obj_conv.is_owned = false;
15169         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
15170         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15171         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15172         CVec_u8Z_free(ret_var);
15173         return ret_arr;
15174 }
15175
15176 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
15177         LDKu8slice ser_ref;
15178         ser_ref.datalen = *((uint32_t*)ser);
15179         ser_ref.data = (int8_t*)(ser + 4);
15180         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15181         *ret_conv = FundingSigned_read(ser_ref);
15182         return (long)ret_conv;
15183 }
15184
15185 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
15186         LDKFundingLocked obj_conv;
15187         obj_conv.inner = (void*)(obj & (~1));
15188         obj_conv.is_owned = false;
15189         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
15190         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15191         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15192         CVec_u8Z_free(ret_var);
15193         return ret_arr;
15194 }
15195
15196 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
15197         LDKu8slice ser_ref;
15198         ser_ref.datalen = *((uint32_t*)ser);
15199         ser_ref.data = (int8_t*)(ser + 4);
15200         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15201         *ret_conv = FundingLocked_read(ser_ref);
15202         return (long)ret_conv;
15203 }
15204
15205 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
15206         LDKInit obj_conv;
15207         obj_conv.inner = (void*)(obj & (~1));
15208         obj_conv.is_owned = false;
15209         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
15210         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15211         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15212         CVec_u8Z_free(ret_var);
15213         return ret_arr;
15214 }
15215
15216 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
15217         LDKu8slice ser_ref;
15218         ser_ref.datalen = *((uint32_t*)ser);
15219         ser_ref.data = (int8_t*)(ser + 4);
15220         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15221         *ret_conv = Init_read(ser_ref);
15222         return (long)ret_conv;
15223 }
15224
15225 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
15226         LDKOpenChannel obj_conv;
15227         obj_conv.inner = (void*)(obj & (~1));
15228         obj_conv.is_owned = false;
15229         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
15230         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15231         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15232         CVec_u8Z_free(ret_var);
15233         return ret_arr;
15234 }
15235
15236 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
15237         LDKu8slice ser_ref;
15238         ser_ref.datalen = *((uint32_t*)ser);
15239         ser_ref.data = (int8_t*)(ser + 4);
15240         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15241         *ret_conv = OpenChannel_read(ser_ref);
15242         return (long)ret_conv;
15243 }
15244
15245 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
15246         LDKRevokeAndACK obj_conv;
15247         obj_conv.inner = (void*)(obj & (~1));
15248         obj_conv.is_owned = false;
15249         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
15250         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15251         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15252         CVec_u8Z_free(ret_var);
15253         return ret_arr;
15254 }
15255
15256 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
15257         LDKu8slice ser_ref;
15258         ser_ref.datalen = *((uint32_t*)ser);
15259         ser_ref.data = (int8_t*)(ser + 4);
15260         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15261         *ret_conv = RevokeAndACK_read(ser_ref);
15262         return (long)ret_conv;
15263 }
15264
15265 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
15266         LDKShutdown obj_conv;
15267         obj_conv.inner = (void*)(obj & (~1));
15268         obj_conv.is_owned = false;
15269         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
15270         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15271         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15272         CVec_u8Z_free(ret_var);
15273         return ret_arr;
15274 }
15275
15276 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
15277         LDKu8slice ser_ref;
15278         ser_ref.datalen = *((uint32_t*)ser);
15279         ser_ref.data = (int8_t*)(ser + 4);
15280         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15281         *ret_conv = Shutdown_read(ser_ref);
15282         return (long)ret_conv;
15283 }
15284
15285 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
15286         LDKUpdateFailHTLC obj_conv;
15287         obj_conv.inner = (void*)(obj & (~1));
15288         obj_conv.is_owned = false;
15289         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
15290         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15291         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15292         CVec_u8Z_free(ret_var);
15293         return ret_arr;
15294 }
15295
15296 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
15297         LDKu8slice ser_ref;
15298         ser_ref.datalen = *((uint32_t*)ser);
15299         ser_ref.data = (int8_t*)(ser + 4);
15300         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15301         *ret_conv = UpdateFailHTLC_read(ser_ref);
15302         return (long)ret_conv;
15303 }
15304
15305 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
15306         LDKUpdateFailMalformedHTLC obj_conv;
15307         obj_conv.inner = (void*)(obj & (~1));
15308         obj_conv.is_owned = false;
15309         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
15310         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15311         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15312         CVec_u8Z_free(ret_var);
15313         return ret_arr;
15314 }
15315
15316 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
15317         LDKu8slice ser_ref;
15318         ser_ref.datalen = *((uint32_t*)ser);
15319         ser_ref.data = (int8_t*)(ser + 4);
15320         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15321         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
15322         return (long)ret_conv;
15323 }
15324
15325 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
15326         LDKUpdateFee obj_conv;
15327         obj_conv.inner = (void*)(obj & (~1));
15328         obj_conv.is_owned = false;
15329         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
15330         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15331         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15332         CVec_u8Z_free(ret_var);
15333         return ret_arr;
15334 }
15335
15336 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
15337         LDKu8slice ser_ref;
15338         ser_ref.datalen = *((uint32_t*)ser);
15339         ser_ref.data = (int8_t*)(ser + 4);
15340         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15341         *ret_conv = UpdateFee_read(ser_ref);
15342         return (long)ret_conv;
15343 }
15344
15345 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
15346         LDKUpdateFulfillHTLC obj_conv;
15347         obj_conv.inner = (void*)(obj & (~1));
15348         obj_conv.is_owned = false;
15349         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
15350         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15351         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15352         CVec_u8Z_free(ret_var);
15353         return ret_arr;
15354 }
15355
15356 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
15357         LDKu8slice ser_ref;
15358         ser_ref.datalen = *((uint32_t*)ser);
15359         ser_ref.data = (int8_t*)(ser + 4);
15360         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15361         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
15362         return (long)ret_conv;
15363 }
15364
15365 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
15366         LDKUpdateAddHTLC obj_conv;
15367         obj_conv.inner = (void*)(obj & (~1));
15368         obj_conv.is_owned = false;
15369         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
15370         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15371         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15372         CVec_u8Z_free(ret_var);
15373         return ret_arr;
15374 }
15375
15376 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
15377         LDKu8slice ser_ref;
15378         ser_ref.datalen = *((uint32_t*)ser);
15379         ser_ref.data = (int8_t*)(ser + 4);
15380         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15381         *ret_conv = UpdateAddHTLC_read(ser_ref);
15382         return (long)ret_conv;
15383 }
15384
15385 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
15386         LDKPing obj_conv;
15387         obj_conv.inner = (void*)(obj & (~1));
15388         obj_conv.is_owned = false;
15389         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
15390         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15391         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15392         CVec_u8Z_free(ret_var);
15393         return ret_arr;
15394 }
15395
15396 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
15397         LDKu8slice ser_ref;
15398         ser_ref.datalen = *((uint32_t*)ser);
15399         ser_ref.data = (int8_t*)(ser + 4);
15400         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15401         *ret_conv = Ping_read(ser_ref);
15402         return (long)ret_conv;
15403 }
15404
15405 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
15406         LDKPong obj_conv;
15407         obj_conv.inner = (void*)(obj & (~1));
15408         obj_conv.is_owned = false;
15409         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
15410         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15411         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15412         CVec_u8Z_free(ret_var);
15413         return ret_arr;
15414 }
15415
15416 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
15417         LDKu8slice ser_ref;
15418         ser_ref.datalen = *((uint32_t*)ser);
15419         ser_ref.data = (int8_t*)(ser + 4);
15420         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15421         *ret_conv = Pong_read(ser_ref);
15422         return (long)ret_conv;
15423 }
15424
15425 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
15426         LDKUnsignedChannelAnnouncement obj_conv;
15427         obj_conv.inner = (void*)(obj & (~1));
15428         obj_conv.is_owned = false;
15429         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
15430         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15431         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15432         CVec_u8Z_free(ret_var);
15433         return ret_arr;
15434 }
15435
15436 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
15437         LDKu8slice ser_ref;
15438         ser_ref.datalen = *((uint32_t*)ser);
15439         ser_ref.data = (int8_t*)(ser + 4);
15440         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15441         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
15442         return (long)ret_conv;
15443 }
15444
15445 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
15446         LDKChannelAnnouncement obj_conv;
15447         obj_conv.inner = (void*)(obj & (~1));
15448         obj_conv.is_owned = false;
15449         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
15450         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15451         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15452         CVec_u8Z_free(ret_var);
15453         return ret_arr;
15454 }
15455
15456 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
15457         LDKu8slice ser_ref;
15458         ser_ref.datalen = *((uint32_t*)ser);
15459         ser_ref.data = (int8_t*)(ser + 4);
15460         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15461         *ret_conv = ChannelAnnouncement_read(ser_ref);
15462         return (long)ret_conv;
15463 }
15464
15465 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
15466         LDKUnsignedChannelUpdate obj_conv;
15467         obj_conv.inner = (void*)(obj & (~1));
15468         obj_conv.is_owned = false;
15469         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
15470         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15471         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15472         CVec_u8Z_free(ret_var);
15473         return ret_arr;
15474 }
15475
15476 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
15477         LDKu8slice ser_ref;
15478         ser_ref.datalen = *((uint32_t*)ser);
15479         ser_ref.data = (int8_t*)(ser + 4);
15480         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15481         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
15482         return (long)ret_conv;
15483 }
15484
15485 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
15486         LDKChannelUpdate obj_conv;
15487         obj_conv.inner = (void*)(obj & (~1));
15488         obj_conv.is_owned = false;
15489         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
15490         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15491         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15492         CVec_u8Z_free(ret_var);
15493         return ret_arr;
15494 }
15495
15496 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
15497         LDKu8slice ser_ref;
15498         ser_ref.datalen = *((uint32_t*)ser);
15499         ser_ref.data = (int8_t*)(ser + 4);
15500         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15501         *ret_conv = ChannelUpdate_read(ser_ref);
15502         return (long)ret_conv;
15503 }
15504
15505 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
15506         LDKErrorMessage obj_conv;
15507         obj_conv.inner = (void*)(obj & (~1));
15508         obj_conv.is_owned = false;
15509         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
15510         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15511         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15512         CVec_u8Z_free(ret_var);
15513         return ret_arr;
15514 }
15515
15516 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
15517         LDKu8slice ser_ref;
15518         ser_ref.datalen = *((uint32_t*)ser);
15519         ser_ref.data = (int8_t*)(ser + 4);
15520         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15521         *ret_conv = ErrorMessage_read(ser_ref);
15522         return (long)ret_conv;
15523 }
15524
15525 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
15526         LDKUnsignedNodeAnnouncement obj_conv;
15527         obj_conv.inner = (void*)(obj & (~1));
15528         obj_conv.is_owned = false;
15529         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
15530         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15531         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15532         CVec_u8Z_free(ret_var);
15533         return ret_arr;
15534 }
15535
15536 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
15537         LDKu8slice ser_ref;
15538         ser_ref.datalen = *((uint32_t*)ser);
15539         ser_ref.data = (int8_t*)(ser + 4);
15540         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15541         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
15542         return (long)ret_conv;
15543 }
15544
15545 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
15546         LDKNodeAnnouncement obj_conv;
15547         obj_conv.inner = (void*)(obj & (~1));
15548         obj_conv.is_owned = false;
15549         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
15550         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15551         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15552         CVec_u8Z_free(ret_var);
15553         return ret_arr;
15554 }
15555
15556 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
15557         LDKu8slice ser_ref;
15558         ser_ref.datalen = *((uint32_t*)ser);
15559         ser_ref.data = (int8_t*)(ser + 4);
15560         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15561         *ret_conv = NodeAnnouncement_read(ser_ref);
15562         return (long)ret_conv;
15563 }
15564
15565 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
15566         LDKu8slice ser_ref;
15567         ser_ref.datalen = *((uint32_t*)ser);
15568         ser_ref.data = (int8_t*)(ser + 4);
15569         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15570         *ret_conv = QueryShortChannelIds_read(ser_ref);
15571         return (long)ret_conv;
15572 }
15573
15574 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
15575         LDKQueryShortChannelIds obj_conv;
15576         obj_conv.inner = (void*)(obj & (~1));
15577         obj_conv.is_owned = false;
15578         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
15579         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15580         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15581         CVec_u8Z_free(ret_var);
15582         return ret_arr;
15583 }
15584
15585 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
15586         LDKu8slice ser_ref;
15587         ser_ref.datalen = *((uint32_t*)ser);
15588         ser_ref.data = (int8_t*)(ser + 4);
15589         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15590         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
15591         return (long)ret_conv;
15592 }
15593
15594 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
15595         LDKReplyShortChannelIdsEnd obj_conv;
15596         obj_conv.inner = (void*)(obj & (~1));
15597         obj_conv.is_owned = false;
15598         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
15599         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15600         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15601         CVec_u8Z_free(ret_var);
15602         return ret_arr;
15603 }
15604
15605 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
15606         LDKu8slice ser_ref;
15607         ser_ref.datalen = *((uint32_t*)ser);
15608         ser_ref.data = (int8_t*)(ser + 4);
15609         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15610         *ret_conv = QueryChannelRange_read(ser_ref);
15611         return (long)ret_conv;
15612 }
15613
15614 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
15615         LDKQueryChannelRange obj_conv;
15616         obj_conv.inner = (void*)(obj & (~1));
15617         obj_conv.is_owned = false;
15618         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
15619         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15620         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15621         CVec_u8Z_free(ret_var);
15622         return ret_arr;
15623 }
15624
15625 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
15626         LDKu8slice ser_ref;
15627         ser_ref.datalen = *((uint32_t*)ser);
15628         ser_ref.data = (int8_t*)(ser + 4);
15629         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15630         *ret_conv = ReplyChannelRange_read(ser_ref);
15631         return (long)ret_conv;
15632 }
15633
15634 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
15635         LDKReplyChannelRange obj_conv;
15636         obj_conv.inner = (void*)(obj & (~1));
15637         obj_conv.is_owned = false;
15638         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
15639         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15640         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15641         CVec_u8Z_free(ret_var);
15642         return ret_arr;
15643 }
15644
15645 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
15646         LDKu8slice ser_ref;
15647         ser_ref.datalen = *((uint32_t*)ser);
15648         ser_ref.data = (int8_t*)(ser + 4);
15649         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15650         *ret_conv = GossipTimestampFilter_read(ser_ref);
15651         return (long)ret_conv;
15652 }
15653
15654 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
15655         LDKGossipTimestampFilter obj_conv;
15656         obj_conv.inner = (void*)(obj & (~1));
15657         obj_conv.is_owned = false;
15658         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
15659         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15660         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15661         CVec_u8Z_free(ret_var);
15662         return ret_arr;
15663 }
15664
15665 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
15666         LDKIgnoringMessageHandler this_obj_conv;
15667         this_obj_conv.inner = (void*)(this_obj & (~1));
15668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15669         IgnoringMessageHandler_free(this_obj_conv);
15670 }
15671
15672 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
15673         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
15674         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15675         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15676         long ret_ref = (long)ret_var.inner;
15677         if (ret_var.is_owned) {
15678                 ret_ref |= 1;
15679         }
15680         return ret_ref;
15681 }
15682
15683 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
15684         LDKIgnoringMessageHandler this_arg_conv;
15685         this_arg_conv.inner = (void*)(this_arg & (~1));
15686         this_arg_conv.is_owned = false;
15687         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15688         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
15689         return (long)ret;
15690 }
15691
15692 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
15693         LDKIgnoringMessageHandler this_arg_conv;
15694         this_arg_conv.inner = (void*)(this_arg & (~1));
15695         this_arg_conv.is_owned = false;
15696         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
15697         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
15698         return (long)ret;
15699 }
15700
15701 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
15702         LDKErroringMessageHandler this_obj_conv;
15703         this_obj_conv.inner = (void*)(this_obj & (~1));
15704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15705         ErroringMessageHandler_free(this_obj_conv);
15706 }
15707
15708 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
15709         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
15710         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15711         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15712         long ret_ref = (long)ret_var.inner;
15713         if (ret_var.is_owned) {
15714                 ret_ref |= 1;
15715         }
15716         return ret_ref;
15717 }
15718
15719 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
15720         LDKErroringMessageHandler this_arg_conv;
15721         this_arg_conv.inner = (void*)(this_arg & (~1));
15722         this_arg_conv.is_owned = false;
15723         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15724         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
15725         return (long)ret;
15726 }
15727
15728 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
15729         LDKErroringMessageHandler this_arg_conv;
15730         this_arg_conv.inner = (void*)(this_arg & (~1));
15731         this_arg_conv.is_owned = false;
15732         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15733         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
15734         return (long)ret;
15735 }
15736
15737 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
15738         LDKMessageHandler this_obj_conv;
15739         this_obj_conv.inner = (void*)(this_obj & (~1));
15740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15741         MessageHandler_free(this_obj_conv);
15742 }
15743
15744 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
15745         LDKMessageHandler this_ptr_conv;
15746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15747         this_ptr_conv.is_owned = false;
15748         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
15749         return ret_ret;
15750 }
15751
15752 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
15753         LDKMessageHandler this_ptr_conv;
15754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15755         this_ptr_conv.is_owned = false;
15756         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
15757         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
15758 }
15759
15760 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
15761         LDKMessageHandler this_ptr_conv;
15762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15763         this_ptr_conv.is_owned = false;
15764         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
15765         return ret_ret;
15766 }
15767
15768 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
15769         LDKMessageHandler this_ptr_conv;
15770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15771         this_ptr_conv.is_owned = false;
15772         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
15773         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
15774 }
15775
15776 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
15777         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
15778         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
15779         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
15780         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15781         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15782         long ret_ref = (long)ret_var.inner;
15783         if (ret_var.is_owned) {
15784                 ret_ref |= 1;
15785         }
15786         return ret_ref;
15787 }
15788
15789 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
15790         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
15791         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15792         *ret = SocketDescriptor_clone(orig_conv);
15793         return (long)ret;
15794 }
15795
15796 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
15797         if ((this_ptr & 1) != 0) return;
15798         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
15799         FREE((void*)this_ptr);
15800         SocketDescriptor_free(this_ptr_conv);
15801 }
15802
15803 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
15804         LDKPeerHandleError this_obj_conv;
15805         this_obj_conv.inner = (void*)(this_obj & (~1));
15806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15807         PeerHandleError_free(this_obj_conv);
15808 }
15809
15810 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
15811         LDKPeerHandleError this_ptr_conv;
15812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15813         this_ptr_conv.is_owned = false;
15814         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
15815         return ret_val;
15816 }
15817
15818 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
15819         LDKPeerHandleError this_ptr_conv;
15820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15821         this_ptr_conv.is_owned = false;
15822         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
15823 }
15824
15825 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
15826         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
15827         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15828         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15829         long ret_ref = (long)ret_var.inner;
15830         if (ret_var.is_owned) {
15831                 ret_ref |= 1;
15832         }
15833         return ret_ref;
15834 }
15835
15836 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
15837         LDKPeerHandleError orig_conv;
15838         orig_conv.inner = (void*)(orig & (~1));
15839         orig_conv.is_owned = false;
15840         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
15841         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15842         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15843         long ret_ref = (long)ret_var.inner;
15844         if (ret_var.is_owned) {
15845                 ret_ref |= 1;
15846         }
15847         return ret_ref;
15848 }
15849
15850 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
15851         LDKPeerManager this_obj_conv;
15852         this_obj_conv.inner = (void*)(this_obj & (~1));
15853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15854         PeerManager_free(this_obj_conv);
15855 }
15856
15857 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) {
15858         LDKMessageHandler message_handler_conv;
15859         message_handler_conv.inner = (void*)(message_handler & (~1));
15860         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
15861         // Warning: we need a move here but no clone is available for LDKMessageHandler
15862         LDKSecretKey our_node_secret_ref;
15863         CHECK(*((uint32_t*)our_node_secret) == 32);
15864         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
15865         unsigned char ephemeral_random_data_arr[32];
15866         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
15867         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
15868         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
15869         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15870         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
15871         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15872         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15873         long ret_ref = (long)ret_var.inner;
15874         if (ret_var.is_owned) {
15875                 ret_ref |= 1;
15876         }
15877         return ret_ref;
15878 }
15879
15880 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
15881         LDKPeerManager this_arg_conv;
15882         this_arg_conv.inner = (void*)(this_arg & (~1));
15883         this_arg_conv.is_owned = false;
15884         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
15885         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
15886         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
15887         for (size_t m = 0; m < ret_var.datalen; m++) {
15888                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15889                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
15890                 ret_arr_ptr[m] = ret_conv_12_arr;
15891         }
15892         FREE(ret_var.data);
15893         return ret_arr;
15894 }
15895
15896 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
15897         LDKPeerManager this_arg_conv;
15898         this_arg_conv.inner = (void*)(this_arg & (~1));
15899         this_arg_conv.is_owned = false;
15900         LDKPublicKey their_node_id_ref;
15901         CHECK(*((uint32_t*)their_node_id) == 33);
15902         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
15903         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15904         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
15905         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
15906         return (long)ret_conv;
15907 }
15908
15909 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
15910         LDKPeerManager this_arg_conv;
15911         this_arg_conv.inner = (void*)(this_arg & (~1));
15912         this_arg_conv.is_owned = false;
15913         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15914         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15915         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
15916         return (long)ret_conv;
15917 }
15918
15919 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
15920         LDKPeerManager this_arg_conv;
15921         this_arg_conv.inner = (void*)(this_arg & (~1));
15922         this_arg_conv.is_owned = false;
15923         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15924         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15925         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
15926         return (long)ret_conv;
15927 }
15928
15929 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
15930         LDKPeerManager this_arg_conv;
15931         this_arg_conv.inner = (void*)(this_arg & (~1));
15932         this_arg_conv.is_owned = false;
15933         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
15934         LDKu8slice data_ref;
15935         data_ref.datalen = *((uint32_t*)data);
15936         data_ref.data = (int8_t*)(data + 4);
15937         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
15938         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
15939         return (long)ret_conv;
15940 }
15941
15942 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
15943         LDKPeerManager this_arg_conv;
15944         this_arg_conv.inner = (void*)(this_arg & (~1));
15945         this_arg_conv.is_owned = false;
15946         PeerManager_process_events(&this_arg_conv);
15947 }
15948
15949 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
15950         LDKPeerManager this_arg_conv;
15951         this_arg_conv.inner = (void*)(this_arg & (~1));
15952         this_arg_conv.is_owned = false;
15953         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15954         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
15955 }
15956
15957 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
15958         LDKPeerManager this_arg_conv;
15959         this_arg_conv.inner = (void*)(this_arg & (~1));
15960         this_arg_conv.is_owned = false;
15961         LDKPublicKey node_id_ref;
15962         CHECK(*((uint32_t*)node_id) == 33);
15963         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
15964         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
15965 }
15966
15967 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occured(uint32_t this_arg) {
15968         LDKPeerManager this_arg_conv;
15969         this_arg_conv.inner = (void*)(this_arg & (~1));
15970         this_arg_conv.is_owned = false;
15971         PeerManager_timer_tick_occured(&this_arg_conv);
15972 }
15973
15974 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
15975         unsigned char commitment_seed_arr[32];
15976         CHECK(*((uint32_t*)commitment_seed) == 32);
15977         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
15978         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
15979         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15980         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
15981         return ret_arr;
15982 }
15983
15984 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
15985         LDKPublicKey per_commitment_point_ref;
15986         CHECK(*((uint32_t*)per_commitment_point) == 33);
15987         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
15988         unsigned char base_secret_arr[32];
15989         CHECK(*((uint32_t*)base_secret) == 32);
15990         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
15991         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
15992         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15993         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
15994         return (long)ret_conv;
15995 }
15996
15997 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
15998         LDKPublicKey per_commitment_point_ref;
15999         CHECK(*((uint32_t*)per_commitment_point) == 33);
16000         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16001         LDKPublicKey base_point_ref;
16002         CHECK(*((uint32_t*)base_point) == 33);
16003         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
16004         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16005         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
16006         return (long)ret_conv;
16007 }
16008
16009 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
16010         unsigned char per_commitment_secret_arr[32];
16011         CHECK(*((uint32_t*)per_commitment_secret) == 32);
16012         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
16013         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
16014         unsigned char countersignatory_revocation_base_secret_arr[32];
16015         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
16016         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
16017         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
16018         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16019         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
16020         return (long)ret_conv;
16021 }
16022
16023 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
16024         LDKPublicKey per_commitment_point_ref;
16025         CHECK(*((uint32_t*)per_commitment_point) == 33);
16026         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16027         LDKPublicKey countersignatory_revocation_base_point_ref;
16028         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
16029         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
16030         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16031         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
16032         return (long)ret_conv;
16033 }
16034
16035 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
16036         LDKTxCreationKeys this_obj_conv;
16037         this_obj_conv.inner = (void*)(this_obj & (~1));
16038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16039         TxCreationKeys_free(this_obj_conv);
16040 }
16041
16042 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
16043         LDKTxCreationKeys this_ptr_conv;
16044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16045         this_ptr_conv.is_owned = false;
16046         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16047         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16048         return ret_arr;
16049 }
16050
16051 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16052         LDKTxCreationKeys this_ptr_conv;
16053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16054         this_ptr_conv.is_owned = false;
16055         LDKPublicKey val_ref;
16056         CHECK(*((uint32_t*)val) == 33);
16057         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16058         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
16059 }
16060
16061 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
16062         LDKTxCreationKeys this_ptr_conv;
16063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16064         this_ptr_conv.is_owned = false;
16065         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16066         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
16067         return ret_arr;
16068 }
16069
16070 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
16071         LDKTxCreationKeys this_ptr_conv;
16072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16073         this_ptr_conv.is_owned = false;
16074         LDKPublicKey val_ref;
16075         CHECK(*((uint32_t*)val) == 33);
16076         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16077         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
16078 }
16079
16080 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
16081         LDKTxCreationKeys this_ptr_conv;
16082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16083         this_ptr_conv.is_owned = false;
16084         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16085         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
16086         return ret_arr;
16087 }
16088
16089 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
16090         LDKTxCreationKeys this_ptr_conv;
16091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16092         this_ptr_conv.is_owned = false;
16093         LDKPublicKey val_ref;
16094         CHECK(*((uint32_t*)val) == 33);
16095         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16096         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
16097 }
16098
16099 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
16100         LDKTxCreationKeys this_ptr_conv;
16101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16102         this_ptr_conv.is_owned = false;
16103         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16104         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
16105         return ret_arr;
16106 }
16107
16108 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
16109         LDKTxCreationKeys this_ptr_conv;
16110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16111         this_ptr_conv.is_owned = false;
16112         LDKPublicKey val_ref;
16113         CHECK(*((uint32_t*)val) == 33);
16114         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16115         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
16116 }
16117
16118 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
16119         LDKTxCreationKeys this_ptr_conv;
16120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16121         this_ptr_conv.is_owned = false;
16122         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16123         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
16124         return ret_arr;
16125 }
16126
16127 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
16128         LDKTxCreationKeys this_ptr_conv;
16129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16130         this_ptr_conv.is_owned = false;
16131         LDKPublicKey val_ref;
16132         CHECK(*((uint32_t*)val) == 33);
16133         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16134         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
16135 }
16136
16137 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) {
16138         LDKPublicKey per_commitment_point_arg_ref;
16139         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
16140         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
16141         LDKPublicKey revocation_key_arg_ref;
16142         CHECK(*((uint32_t*)revocation_key_arg) == 33);
16143         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
16144         LDKPublicKey broadcaster_htlc_key_arg_ref;
16145         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
16146         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
16147         LDKPublicKey countersignatory_htlc_key_arg_ref;
16148         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
16149         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
16150         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
16151         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
16152         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
16153         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);
16154         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16155         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16156         long ret_ref = (long)ret_var.inner;
16157         if (ret_var.is_owned) {
16158                 ret_ref |= 1;
16159         }
16160         return ret_ref;
16161 }
16162
16163 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
16164         LDKTxCreationKeys orig_conv;
16165         orig_conv.inner = (void*)(orig & (~1));
16166         orig_conv.is_owned = false;
16167         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
16168         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16169         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16170         long ret_ref = (long)ret_var.inner;
16171         if (ret_var.is_owned) {
16172                 ret_ref |= 1;
16173         }
16174         return ret_ref;
16175 }
16176
16177 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
16178         LDKTxCreationKeys obj_conv;
16179         obj_conv.inner = (void*)(obj & (~1));
16180         obj_conv.is_owned = false;
16181         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
16182         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16183         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16184         CVec_u8Z_free(ret_var);
16185         return ret_arr;
16186 }
16187
16188 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
16189         LDKu8slice ser_ref;
16190         ser_ref.datalen = *((uint32_t*)ser);
16191         ser_ref.data = (int8_t*)(ser + 4);
16192         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16193         *ret_conv = TxCreationKeys_read(ser_ref);
16194         return (long)ret_conv;
16195 }
16196
16197 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
16198         LDKChannelPublicKeys this_obj_conv;
16199         this_obj_conv.inner = (void*)(this_obj & (~1));
16200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16201         ChannelPublicKeys_free(this_obj_conv);
16202 }
16203
16204 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
16205         LDKChannelPublicKeys this_ptr_conv;
16206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16207         this_ptr_conv.is_owned = false;
16208         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16209         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16210         return ret_arr;
16211 }
16212
16213 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16214         LDKChannelPublicKeys this_ptr_conv;
16215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16216         this_ptr_conv.is_owned = false;
16217         LDKPublicKey val_ref;
16218         CHECK(*((uint32_t*)val) == 33);
16219         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16220         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
16221 }
16222
16223 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
16224         LDKChannelPublicKeys this_ptr_conv;
16225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16226         this_ptr_conv.is_owned = false;
16227         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16228         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16229         return ret_arr;
16230 }
16231
16232 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16233         LDKChannelPublicKeys this_ptr_conv;
16234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16235         this_ptr_conv.is_owned = false;
16236         LDKPublicKey val_ref;
16237         CHECK(*((uint32_t*)val) == 33);
16238         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16239         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
16240 }
16241
16242 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
16243         LDKChannelPublicKeys this_ptr_conv;
16244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16245         this_ptr_conv.is_owned = false;
16246         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16247         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
16248         return ret_arr;
16249 }
16250
16251 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16252         LDKChannelPublicKeys this_ptr_conv;
16253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16254         this_ptr_conv.is_owned = false;
16255         LDKPublicKey val_ref;
16256         CHECK(*((uint32_t*)val) == 33);
16257         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16258         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
16259 }
16260
16261 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
16262         LDKChannelPublicKeys this_ptr_conv;
16263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16264         this_ptr_conv.is_owned = false;
16265         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16266         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16267         return ret_arr;
16268 }
16269
16270 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16271         LDKChannelPublicKeys this_ptr_conv;
16272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16273         this_ptr_conv.is_owned = false;
16274         LDKPublicKey val_ref;
16275         CHECK(*((uint32_t*)val) == 33);
16276         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16277         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16278 }
16279
16280 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
16281         LDKChannelPublicKeys this_ptr_conv;
16282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16283         this_ptr_conv.is_owned = false;
16284         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16285         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16286         return ret_arr;
16287 }
16288
16289 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16290         LDKChannelPublicKeys this_ptr_conv;
16291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16292         this_ptr_conv.is_owned = false;
16293         LDKPublicKey val_ref;
16294         CHECK(*((uint32_t*)val) == 33);
16295         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16296         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
16297 }
16298
16299 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) {
16300         LDKPublicKey funding_pubkey_arg_ref;
16301         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
16302         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
16303         LDKPublicKey revocation_basepoint_arg_ref;
16304         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
16305         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
16306         LDKPublicKey payment_point_arg_ref;
16307         CHECK(*((uint32_t*)payment_point_arg) == 33);
16308         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
16309         LDKPublicKey delayed_payment_basepoint_arg_ref;
16310         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
16311         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
16312         LDKPublicKey htlc_basepoint_arg_ref;
16313         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
16314         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
16315         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);
16316         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16317         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16318         long ret_ref = (long)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_ChannelPublicKeys_clone(uint32_t orig) {
16326         LDKChannelPublicKeys orig_conv;
16327         orig_conv.inner = (void*)(orig & (~1));
16328         orig_conv.is_owned = false;
16329         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
16330         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16331         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16332         long ret_ref = (long)ret_var.inner;
16333         if (ret_var.is_owned) {
16334                 ret_ref |= 1;
16335         }
16336         return ret_ref;
16337 }
16338
16339 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
16340         LDKChannelPublicKeys obj_conv;
16341         obj_conv.inner = (void*)(obj & (~1));
16342         obj_conv.is_owned = false;
16343         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
16344         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16345         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16346         CVec_u8Z_free(ret_var);
16347         return ret_arr;
16348 }
16349
16350 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
16351         LDKu8slice ser_ref;
16352         ser_ref.datalen = *((uint32_t*)ser);
16353         ser_ref.data = (int8_t*)(ser + 4);
16354         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16355         *ret_conv = ChannelPublicKeys_read(ser_ref);
16356         return (long)ret_conv;
16357 }
16358
16359 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) {
16360         LDKPublicKey per_commitment_point_ref;
16361         CHECK(*((uint32_t*)per_commitment_point) == 33);
16362         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16363         LDKPublicKey broadcaster_delayed_payment_base_ref;
16364         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
16365         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
16366         LDKPublicKey broadcaster_htlc_base_ref;
16367         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
16368         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
16369         LDKPublicKey countersignatory_revocation_base_ref;
16370         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
16371         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
16372         LDKPublicKey countersignatory_htlc_base_ref;
16373         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
16374         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
16375         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16376         *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);
16377         return (long)ret_conv;
16378 }
16379
16380 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
16381         LDKPublicKey per_commitment_point_ref;
16382         CHECK(*((uint32_t*)per_commitment_point) == 33);
16383         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16384         LDKChannelPublicKeys broadcaster_keys_conv;
16385         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
16386         broadcaster_keys_conv.is_owned = false;
16387         LDKChannelPublicKeys countersignatory_keys_conv;
16388         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
16389         countersignatory_keys_conv.is_owned = false;
16390         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16391         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
16392         return (long)ret_conv;
16393 }
16394
16395 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
16396         LDKPublicKey revocation_key_ref;
16397         CHECK(*((uint32_t*)revocation_key) == 33);
16398         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16399         LDKPublicKey broadcaster_delayed_payment_key_ref;
16400         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16401         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16402         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
16403         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16404         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16405         CVec_u8Z_free(ret_var);
16406         return ret_arr;
16407 }
16408
16409 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
16410         LDKHTLCOutputInCommitment this_obj_conv;
16411         this_obj_conv.inner = (void*)(this_obj & (~1));
16412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16413         HTLCOutputInCommitment_free(this_obj_conv);
16414 }
16415
16416 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
16417         LDKHTLCOutputInCommitment this_ptr_conv;
16418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16419         this_ptr_conv.is_owned = false;
16420         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
16421         return ret_val;
16422 }
16423
16424 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
16425         LDKHTLCOutputInCommitment this_ptr_conv;
16426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16427         this_ptr_conv.is_owned = false;
16428         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
16429 }
16430
16431 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
16432         LDKHTLCOutputInCommitment this_ptr_conv;
16433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16434         this_ptr_conv.is_owned = false;
16435         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
16436         return ret_val;
16437 }
16438
16439 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
16440         LDKHTLCOutputInCommitment this_ptr_conv;
16441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16442         this_ptr_conv.is_owned = false;
16443         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
16444 }
16445
16446 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
16447         LDKHTLCOutputInCommitment this_ptr_conv;
16448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16449         this_ptr_conv.is_owned = false;
16450         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
16451         return ret_val;
16452 }
16453
16454 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
16455         LDKHTLCOutputInCommitment this_ptr_conv;
16456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16457         this_ptr_conv.is_owned = false;
16458         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
16459 }
16460
16461 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
16462         LDKHTLCOutputInCommitment this_ptr_conv;
16463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16464         this_ptr_conv.is_owned = false;
16465         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16466         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
16467         return ret_arr;
16468 }
16469
16470 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
16471         LDKHTLCOutputInCommitment this_ptr_conv;
16472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16473         this_ptr_conv.is_owned = false;
16474         LDKThirtyTwoBytes val_ref;
16475         CHECK(*((uint32_t*)val) == 32);
16476         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16477         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
16478 }
16479
16480 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
16481         LDKHTLCOutputInCommitment orig_conv;
16482         orig_conv.inner = (void*)(orig & (~1));
16483         orig_conv.is_owned = false;
16484         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
16485         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16486         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16487         long ret_ref = (long)ret_var.inner;
16488         if (ret_var.is_owned) {
16489                 ret_ref |= 1;
16490         }
16491         return ret_ref;
16492 }
16493
16494 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
16495         LDKHTLCOutputInCommitment obj_conv;
16496         obj_conv.inner = (void*)(obj & (~1));
16497         obj_conv.is_owned = false;
16498         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
16499         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16500         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16501         CVec_u8Z_free(ret_var);
16502         return ret_arr;
16503 }
16504
16505 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
16506         LDKu8slice ser_ref;
16507         ser_ref.datalen = *((uint32_t*)ser);
16508         ser_ref.data = (int8_t*)(ser + 4);
16509         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16510         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
16511         return (long)ret_conv;
16512 }
16513
16514 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
16515         LDKHTLCOutputInCommitment htlc_conv;
16516         htlc_conv.inner = (void*)(htlc & (~1));
16517         htlc_conv.is_owned = false;
16518         LDKTxCreationKeys keys_conv;
16519         keys_conv.inner = (void*)(keys & (~1));
16520         keys_conv.is_owned = false;
16521         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
16522         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16523         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16524         CVec_u8Z_free(ret_var);
16525         return ret_arr;
16526 }
16527
16528 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
16529         LDKPublicKey broadcaster_ref;
16530         CHECK(*((uint32_t*)broadcaster) == 33);
16531         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
16532         LDKPublicKey countersignatory_ref;
16533         CHECK(*((uint32_t*)countersignatory) == 33);
16534         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
16535         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
16536         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16537         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16538         CVec_u8Z_free(ret_var);
16539         return ret_arr;
16540 }
16541
16542 int8_tArray  __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray prev_hash, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
16543         unsigned char prev_hash_arr[32];
16544         CHECK(*((uint32_t*)prev_hash) == 32);
16545         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
16546         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
16547         LDKHTLCOutputInCommitment htlc_conv;
16548         htlc_conv.inner = (void*)(htlc & (~1));
16549         htlc_conv.is_owned = false;
16550         LDKPublicKey broadcaster_delayed_payment_key_ref;
16551         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16552         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16553         LDKPublicKey revocation_key_ref;
16554         CHECK(*((uint32_t*)revocation_key) == 33);
16555         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16556         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
16557         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16558         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16559         Transaction_free(ret_var);
16560         return ret_arr;
16561 }
16562
16563 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
16564         LDKChannelTransactionParameters this_obj_conv;
16565         this_obj_conv.inner = (void*)(this_obj & (~1));
16566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16567         ChannelTransactionParameters_free(this_obj_conv);
16568 }
16569
16570 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
16571         LDKChannelTransactionParameters this_ptr_conv;
16572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16573         this_ptr_conv.is_owned = false;
16574         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
16575         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16576         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16577         long ret_ref = (long)ret_var.inner;
16578         if (ret_var.is_owned) {
16579                 ret_ref |= 1;
16580         }
16581         return ret_ref;
16582 }
16583
16584 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
16585         LDKChannelTransactionParameters this_ptr_conv;
16586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16587         this_ptr_conv.is_owned = false;
16588         LDKChannelPublicKeys val_conv;
16589         val_conv.inner = (void*)(val & (~1));
16590         val_conv.is_owned = (val & 1) || (val == 0);
16591         val_conv = ChannelPublicKeys_clone(&val_conv);
16592         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
16593 }
16594
16595 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
16596         LDKChannelTransactionParameters this_ptr_conv;
16597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16598         this_ptr_conv.is_owned = false;
16599         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
16600         return ret_val;
16601 }
16602
16603 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
16604         LDKChannelTransactionParameters this_ptr_conv;
16605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16606         this_ptr_conv.is_owned = false;
16607         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
16608 }
16609
16610 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
16611         LDKChannelTransactionParameters this_ptr_conv;
16612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16613         this_ptr_conv.is_owned = false;
16614         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
16615         return ret_val;
16616 }
16617
16618 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
16619         LDKChannelTransactionParameters this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
16623 }
16624
16625 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
16626         LDKChannelTransactionParameters this_ptr_conv;
16627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16628         this_ptr_conv.is_owned = false;
16629         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
16630         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16631         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16632         long ret_ref = (long)ret_var.inner;
16633         if (ret_var.is_owned) {
16634                 ret_ref |= 1;
16635         }
16636         return ret_ref;
16637 }
16638
16639 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
16640         LDKChannelTransactionParameters this_ptr_conv;
16641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16642         this_ptr_conv.is_owned = false;
16643         LDKCounterpartyChannelTransactionParameters val_conv;
16644         val_conv.inner = (void*)(val & (~1));
16645         val_conv.is_owned = (val & 1) || (val == 0);
16646         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
16647         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
16648 }
16649
16650 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
16651         LDKChannelTransactionParameters this_ptr_conv;
16652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16653         this_ptr_conv.is_owned = false;
16654         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
16655         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16656         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16657         long ret_ref = (long)ret_var.inner;
16658         if (ret_var.is_owned) {
16659                 ret_ref |= 1;
16660         }
16661         return ret_ref;
16662 }
16663
16664 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
16665         LDKChannelTransactionParameters this_ptr_conv;
16666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16667         this_ptr_conv.is_owned = false;
16668         LDKOutPoint val_conv;
16669         val_conv.inner = (void*)(val & (~1));
16670         val_conv.is_owned = (val & 1) || (val == 0);
16671         val_conv = OutPoint_clone(&val_conv);
16672         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
16673 }
16674
16675 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) {
16676         LDKChannelPublicKeys holder_pubkeys_arg_conv;
16677         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
16678         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
16679         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
16680         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
16681         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
16682         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
16683         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
16684         LDKOutPoint funding_outpoint_arg_conv;
16685         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
16686         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
16687         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
16688         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);
16689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16691         long ret_ref = (long)ret_var.inner;
16692         if (ret_var.is_owned) {
16693                 ret_ref |= 1;
16694         }
16695         return ret_ref;
16696 }
16697
16698 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
16699         LDKChannelTransactionParameters orig_conv;
16700         orig_conv.inner = (void*)(orig & (~1));
16701         orig_conv.is_owned = false;
16702         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
16703         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16704         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16705         long ret_ref = (long)ret_var.inner;
16706         if (ret_var.is_owned) {
16707                 ret_ref |= 1;
16708         }
16709         return ret_ref;
16710 }
16711
16712 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
16713         LDKCounterpartyChannelTransactionParameters this_obj_conv;
16714         this_obj_conv.inner = (void*)(this_obj & (~1));
16715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16716         CounterpartyChannelTransactionParameters_free(this_obj_conv);
16717 }
16718
16719 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
16720         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16722         this_ptr_conv.is_owned = false;
16723         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
16724         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16725         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16726         long ret_ref = (long)ret_var.inner;
16727         if (ret_var.is_owned) {
16728                 ret_ref |= 1;
16729         }
16730         return ret_ref;
16731 }
16732
16733 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
16734         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16736         this_ptr_conv.is_owned = false;
16737         LDKChannelPublicKeys val_conv;
16738         val_conv.inner = (void*)(val & (~1));
16739         val_conv.is_owned = (val & 1) || (val == 0);
16740         val_conv = ChannelPublicKeys_clone(&val_conv);
16741         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
16742 }
16743
16744 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
16745         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16747         this_ptr_conv.is_owned = false;
16748         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
16749         return ret_val;
16750 }
16751
16752 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
16753         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16755         this_ptr_conv.is_owned = false;
16756         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
16757 }
16758
16759 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
16760         LDKChannelPublicKeys pubkeys_arg_conv;
16761         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
16762         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
16763         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
16764         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
16765         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16766         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16767         long ret_ref = (long)ret_var.inner;
16768         if (ret_var.is_owned) {
16769                 ret_ref |= 1;
16770         }
16771         return ret_ref;
16772 }
16773
16774 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
16775         LDKCounterpartyChannelTransactionParameters orig_conv;
16776         orig_conv.inner = (void*)(orig & (~1));
16777         orig_conv.is_owned = false;
16778         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
16779         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16780         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16781         long ret_ref = (long)ret_var.inner;
16782         if (ret_var.is_owned) {
16783                 ret_ref |= 1;
16784         }
16785         return ret_ref;
16786 }
16787
16788 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
16789         LDKChannelTransactionParameters this_arg_conv;
16790         this_arg_conv.inner = (void*)(this_arg & (~1));
16791         this_arg_conv.is_owned = false;
16792         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
16793         return ret_val;
16794 }
16795
16796 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
16797         LDKChannelTransactionParameters this_arg_conv;
16798         this_arg_conv.inner = (void*)(this_arg & (~1));
16799         this_arg_conv.is_owned = false;
16800         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
16801         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16802         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16803         long ret_ref = (long)ret_var.inner;
16804         if (ret_var.is_owned) {
16805                 ret_ref |= 1;
16806         }
16807         return ret_ref;
16808 }
16809
16810 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
16811         LDKChannelTransactionParameters this_arg_conv;
16812         this_arg_conv.inner = (void*)(this_arg & (~1));
16813         this_arg_conv.is_owned = false;
16814         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
16815         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16816         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16817         long ret_ref = (long)ret_var.inner;
16818         if (ret_var.is_owned) {
16819                 ret_ref |= 1;
16820         }
16821         return ret_ref;
16822 }
16823
16824 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
16825         LDKCounterpartyChannelTransactionParameters obj_conv;
16826         obj_conv.inner = (void*)(obj & (~1));
16827         obj_conv.is_owned = false;
16828         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
16829         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16830         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16831         CVec_u8Z_free(ret_var);
16832         return ret_arr;
16833 }
16834
16835 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
16836         LDKu8slice ser_ref;
16837         ser_ref.datalen = *((uint32_t*)ser);
16838         ser_ref.data = (int8_t*)(ser + 4);
16839         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16840         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
16841         return (long)ret_conv;
16842 }
16843
16844 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
16845         LDKChannelTransactionParameters obj_conv;
16846         obj_conv.inner = (void*)(obj & (~1));
16847         obj_conv.is_owned = false;
16848         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
16849         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16850         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16851         CVec_u8Z_free(ret_var);
16852         return ret_arr;
16853 }
16854
16855 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
16856         LDKu8slice ser_ref;
16857         ser_ref.datalen = *((uint32_t*)ser);
16858         ser_ref.data = (int8_t*)(ser + 4);
16859         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16860         *ret_conv = ChannelTransactionParameters_read(ser_ref);
16861         return (long)ret_conv;
16862 }
16863
16864 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
16865         LDKDirectedChannelTransactionParameters this_obj_conv;
16866         this_obj_conv.inner = (void*)(this_obj & (~1));
16867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16868         DirectedChannelTransactionParameters_free(this_obj_conv);
16869 }
16870
16871 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
16872         LDKDirectedChannelTransactionParameters this_arg_conv;
16873         this_arg_conv.inner = (void*)(this_arg & (~1));
16874         this_arg_conv.is_owned = false;
16875         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
16876         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16877         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16878         long ret_ref = (long)ret_var.inner;
16879         if (ret_var.is_owned) {
16880                 ret_ref |= 1;
16881         }
16882         return ret_ref;
16883 }
16884
16885 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
16886         LDKDirectedChannelTransactionParameters this_arg_conv;
16887         this_arg_conv.inner = (void*)(this_arg & (~1));
16888         this_arg_conv.is_owned = false;
16889         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
16890         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16891         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16892         long ret_ref = (long)ret_var.inner;
16893         if (ret_var.is_owned) {
16894                 ret_ref |= 1;
16895         }
16896         return ret_ref;
16897 }
16898
16899 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
16900         LDKDirectedChannelTransactionParameters this_arg_conv;
16901         this_arg_conv.inner = (void*)(this_arg & (~1));
16902         this_arg_conv.is_owned = false;
16903         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
16904         return ret_val;
16905 }
16906
16907 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
16908         LDKDirectedChannelTransactionParameters this_arg_conv;
16909         this_arg_conv.inner = (void*)(this_arg & (~1));
16910         this_arg_conv.is_owned = false;
16911         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
16912         return ret_val;
16913 }
16914
16915 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
16916         LDKDirectedChannelTransactionParameters this_arg_conv;
16917         this_arg_conv.inner = (void*)(this_arg & (~1));
16918         this_arg_conv.is_owned = false;
16919         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
16920         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16921         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16922         long ret_ref = (long)ret_var.inner;
16923         if (ret_var.is_owned) {
16924                 ret_ref |= 1;
16925         }
16926         return ret_ref;
16927 }
16928
16929 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
16930         LDKHolderCommitmentTransaction this_obj_conv;
16931         this_obj_conv.inner = (void*)(this_obj & (~1));
16932         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16933         HolderCommitmentTransaction_free(this_obj_conv);
16934 }
16935
16936 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
16937         LDKHolderCommitmentTransaction this_ptr_conv;
16938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16939         this_ptr_conv.is_owned = false;
16940         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16941         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
16942         return ret_arr;
16943 }
16944
16945 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
16946         LDKHolderCommitmentTransaction this_ptr_conv;
16947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16948         this_ptr_conv.is_owned = false;
16949         LDKSignature val_ref;
16950         CHECK(*((uint32_t*)val) == 64);
16951         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
16952         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
16953 }
16954
16955 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
16956         LDKHolderCommitmentTransaction this_ptr_conv;
16957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16958         this_ptr_conv.is_owned = false;
16959         LDKCVec_SignatureZ val_constr;
16960         val_constr.datalen = *((uint32_t*)val);
16961         if (val_constr.datalen > 0)
16962                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16963         else
16964                 val_constr.data = NULL;
16965         int8_tArray* val_vals = (int8_tArray*)(val + 4);
16966         for (size_t m = 0; m < val_constr.datalen; m++) {
16967                 int8_tArray val_conv_12 = val_vals[m];
16968                 LDKSignature val_conv_12_ref;
16969                 CHECK(*((uint32_t*)val_conv_12) == 64);
16970                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
16971                 val_constr.data[m] = val_conv_12_ref;
16972         }
16973         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
16974 }
16975
16976 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
16977         LDKHolderCommitmentTransaction orig_conv;
16978         orig_conv.inner = (void*)(orig & (~1));
16979         orig_conv.is_owned = false;
16980         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
16981         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16982         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16983         long ret_ref = (long)ret_var.inner;
16984         if (ret_var.is_owned) {
16985                 ret_ref |= 1;
16986         }
16987         return ret_ref;
16988 }
16989
16990 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
16991         LDKHolderCommitmentTransaction obj_conv;
16992         obj_conv.inner = (void*)(obj & (~1));
16993         obj_conv.is_owned = false;
16994         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
16995         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16996         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16997         CVec_u8Z_free(ret_var);
16998         return ret_arr;
16999 }
17000
17001 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
17002         LDKu8slice ser_ref;
17003         ser_ref.datalen = *((uint32_t*)ser);
17004         ser_ref.data = (int8_t*)(ser + 4);
17005         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
17006         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
17007         return (long)ret_conv;
17008 }
17009
17010 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) {
17011         LDKCommitmentTransaction commitment_tx_conv;
17012         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
17013         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
17014         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
17015         LDKSignature counterparty_sig_ref;
17016         CHECK(*((uint32_t*)counterparty_sig) == 64);
17017         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
17018         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
17019         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
17020         if (counterparty_htlc_sigs_constr.datalen > 0)
17021                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17022         else
17023                 counterparty_htlc_sigs_constr.data = NULL;
17024         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
17025         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
17026                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
17027                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
17028                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
17029                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
17030                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
17031         }
17032         LDKPublicKey holder_funding_key_ref;
17033         CHECK(*((uint32_t*)holder_funding_key) == 33);
17034         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
17035         LDKPublicKey counterparty_funding_key_ref;
17036         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
17037         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
17038         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
17039         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17040         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17041         long ret_ref = (long)ret_var.inner;
17042         if (ret_var.is_owned) {
17043                 ret_ref |= 1;
17044         }
17045         return ret_ref;
17046 }
17047
17048 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
17049         LDKBuiltCommitmentTransaction this_obj_conv;
17050         this_obj_conv.inner = (void*)(this_obj & (~1));
17051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17052         BuiltCommitmentTransaction_free(this_obj_conv);
17053 }
17054
17055 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
17056         LDKBuiltCommitmentTransaction this_ptr_conv;
17057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17058         this_ptr_conv.is_owned = false;
17059         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
17060         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17061         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17062         Transaction_free(ret_var);
17063         return ret_arr;
17064 }
17065
17066 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
17067         LDKBuiltCommitmentTransaction this_ptr_conv;
17068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17069         this_ptr_conv.is_owned = false;
17070         LDKTransaction val_ref;
17071         val_ref.datalen = *((uint32_t*)val);
17072         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
17073         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17074         val_ref.data_is_owned = true;
17075         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
17076 }
17077
17078 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
17079         LDKBuiltCommitmentTransaction this_ptr_conv;
17080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17081         this_ptr_conv.is_owned = false;
17082         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17083         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
17084         return ret_arr;
17085 }
17086
17087 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
17088         LDKBuiltCommitmentTransaction this_ptr_conv;
17089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17090         this_ptr_conv.is_owned = false;
17091         LDKThirtyTwoBytes val_ref;
17092         CHECK(*((uint32_t*)val) == 32);
17093         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17094         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
17095 }
17096
17097 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
17098         LDKTransaction transaction_arg_ref;
17099         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
17100         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
17101         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
17102         transaction_arg_ref.data_is_owned = true;
17103         LDKThirtyTwoBytes txid_arg_ref;
17104         CHECK(*((uint32_t*)txid_arg) == 32);
17105         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
17106         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
17107         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17108         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17109         long ret_ref = (long)ret_var.inner;
17110         if (ret_var.is_owned) {
17111                 ret_ref |= 1;
17112         }
17113         return ret_ref;
17114 }
17115
17116 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
17117         LDKBuiltCommitmentTransaction orig_conv;
17118         orig_conv.inner = (void*)(orig & (~1));
17119         orig_conv.is_owned = false;
17120         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
17121         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17122         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17123         long ret_ref = (long)ret_var.inner;
17124         if (ret_var.is_owned) {
17125                 ret_ref |= 1;
17126         }
17127         return ret_ref;
17128 }
17129
17130 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
17131         LDKBuiltCommitmentTransaction obj_conv;
17132         obj_conv.inner = (void*)(obj & (~1));
17133         obj_conv.is_owned = false;
17134         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
17135         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17136         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17137         CVec_u8Z_free(ret_var);
17138         return ret_arr;
17139 }
17140
17141 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
17142         LDKu8slice ser_ref;
17143         ser_ref.datalen = *((uint32_t*)ser);
17144         ser_ref.data = (int8_t*)(ser + 4);
17145         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17146         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
17147         return (long)ret_conv;
17148 }
17149
17150 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
17151         LDKBuiltCommitmentTransaction this_arg_conv;
17152         this_arg_conv.inner = (void*)(this_arg & (~1));
17153         this_arg_conv.is_owned = false;
17154         LDKu8slice funding_redeemscript_ref;
17155         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17156         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17157         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17158         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
17159         return ret_arr;
17160 }
17161
17162 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) {
17163         LDKBuiltCommitmentTransaction this_arg_conv;
17164         this_arg_conv.inner = (void*)(this_arg & (~1));
17165         this_arg_conv.is_owned = false;
17166         unsigned char funding_key_arr[32];
17167         CHECK(*((uint32_t*)funding_key) == 32);
17168         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
17169         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
17170         LDKu8slice funding_redeemscript_ref;
17171         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17172         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17173         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17174         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
17175         return ret_arr;
17176 }
17177
17178 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
17179         LDKCommitmentTransaction this_obj_conv;
17180         this_obj_conv.inner = (void*)(this_obj & (~1));
17181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17182         CommitmentTransaction_free(this_obj_conv);
17183 }
17184
17185 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
17186         LDKCommitmentTransaction orig_conv;
17187         orig_conv.inner = (void*)(orig & (~1));
17188         orig_conv.is_owned = false;
17189         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
17190         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17191         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17192         long ret_ref = (long)ret_var.inner;
17193         if (ret_var.is_owned) {
17194                 ret_ref |= 1;
17195         }
17196         return ret_ref;
17197 }
17198
17199 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
17200         LDKCommitmentTransaction obj_conv;
17201         obj_conv.inner = (void*)(obj & (~1));
17202         obj_conv.is_owned = false;
17203         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
17204         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17205         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17206         CVec_u8Z_free(ret_var);
17207         return ret_arr;
17208 }
17209
17210 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
17211         LDKu8slice ser_ref;
17212         ser_ref.datalen = *((uint32_t*)ser);
17213         ser_ref.data = (int8_t*)(ser + 4);
17214         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17215         *ret_conv = CommitmentTransaction_read(ser_ref);
17216         return (long)ret_conv;
17217 }
17218
17219 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
17220         LDKCommitmentTransaction this_arg_conv;
17221         this_arg_conv.inner = (void*)(this_arg & (~1));
17222         this_arg_conv.is_owned = false;
17223         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
17224         return ret_val;
17225 }
17226
17227 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
17228         LDKCommitmentTransaction this_arg_conv;
17229         this_arg_conv.inner = (void*)(this_arg & (~1));
17230         this_arg_conv.is_owned = false;
17231         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
17232         return ret_val;
17233 }
17234
17235 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
17236         LDKCommitmentTransaction this_arg_conv;
17237         this_arg_conv.inner = (void*)(this_arg & (~1));
17238         this_arg_conv.is_owned = false;
17239         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
17240         return ret_val;
17241 }
17242
17243 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
17244         LDKCommitmentTransaction this_arg_conv;
17245         this_arg_conv.inner = (void*)(this_arg & (~1));
17246         this_arg_conv.is_owned = false;
17247         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
17248         return ret_val;
17249 }
17250
17251 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
17252         LDKCommitmentTransaction this_arg_conv;
17253         this_arg_conv.inner = (void*)(this_arg & (~1));
17254         this_arg_conv.is_owned = false;
17255         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
17256         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17257         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17258         long ret_ref = (long)ret_var.inner;
17259         if (ret_var.is_owned) {
17260                 ret_ref |= 1;
17261         }
17262         return ret_ref;
17263 }
17264
17265 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
17266         LDKCommitmentTransaction this_arg_conv;
17267         this_arg_conv.inner = (void*)(this_arg & (~1));
17268         this_arg_conv.is_owned = false;
17269         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17270         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17271         channel_parameters_conv.is_owned = false;
17272         LDKChannelPublicKeys broadcaster_keys_conv;
17273         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17274         broadcaster_keys_conv.is_owned = false;
17275         LDKChannelPublicKeys countersignatory_keys_conv;
17276         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17277         countersignatory_keys_conv.is_owned = false;
17278         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17279         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
17280         return (long)ret_conv;
17281 }
17282
17283 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
17284         LDKTrustedCommitmentTransaction this_obj_conv;
17285         this_obj_conv.inner = (void*)(this_obj & (~1));
17286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17287         TrustedCommitmentTransaction_free(this_obj_conv);
17288 }
17289
17290 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
17291         LDKTrustedCommitmentTransaction this_arg_conv;
17292         this_arg_conv.inner = (void*)(this_arg & (~1));
17293         this_arg_conv.is_owned = false;
17294         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17295         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
17296         return ret_arr;
17297 }
17298
17299 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
17300         LDKTrustedCommitmentTransaction this_arg_conv;
17301         this_arg_conv.inner = (void*)(this_arg & (~1));
17302         this_arg_conv.is_owned = false;
17303         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
17304         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17305         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17306         long ret_ref = (long)ret_var.inner;
17307         if (ret_var.is_owned) {
17308                 ret_ref |= 1;
17309         }
17310         return ret_ref;
17311 }
17312
17313 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
17314         LDKTrustedCommitmentTransaction this_arg_conv;
17315         this_arg_conv.inner = (void*)(this_arg & (~1));
17316         this_arg_conv.is_owned = false;
17317         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
17318         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17319         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17320         long ret_ref = (long)ret_var.inner;
17321         if (ret_var.is_owned) {
17322                 ret_ref |= 1;
17323         }
17324         return ret_ref;
17325 }
17326
17327 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
17328         LDKTrustedCommitmentTransaction this_arg_conv;
17329         this_arg_conv.inner = (void*)(this_arg & (~1));
17330         this_arg_conv.is_owned = false;
17331         unsigned char htlc_base_key_arr[32];
17332         CHECK(*((uint32_t*)htlc_base_key) == 32);
17333         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
17334         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
17335         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17336         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17337         channel_parameters_conv.is_owned = false;
17338         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17339         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
17340         return (long)ret_conv;
17341 }
17342
17343 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) {
17344         LDKPublicKey broadcaster_payment_basepoint_ref;
17345         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
17346         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
17347         LDKPublicKey countersignatory_payment_basepoint_ref;
17348         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
17349         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
17350         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
17351         return ret_val;
17352 }
17353
17354 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
17355         LDKInitFeatures orig_conv;
17356         orig_conv.inner = (void*)(orig & (~1));
17357         orig_conv.is_owned = false;
17358         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
17359         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17360         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17361         long ret_ref = (long)ret_var.inner;
17362         if (ret_var.is_owned) {
17363                 ret_ref |= 1;
17364         }
17365         return ret_ref;
17366 }
17367
17368 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
17369         LDKNodeFeatures orig_conv;
17370         orig_conv.inner = (void*)(orig & (~1));
17371         orig_conv.is_owned = false;
17372         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
17373         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17374         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17375         long ret_ref = (long)ret_var.inner;
17376         if (ret_var.is_owned) {
17377                 ret_ref |= 1;
17378         }
17379         return ret_ref;
17380 }
17381
17382 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
17383         LDKChannelFeatures orig_conv;
17384         orig_conv.inner = (void*)(orig & (~1));
17385         orig_conv.is_owned = false;
17386         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
17387         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17388         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17389         long ret_ref = (long)ret_var.inner;
17390         if (ret_var.is_owned) {
17391                 ret_ref |= 1;
17392         }
17393         return ret_ref;
17394 }
17395
17396 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
17397         LDKInitFeatures this_obj_conv;
17398         this_obj_conv.inner = (void*)(this_obj & (~1));
17399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17400         InitFeatures_free(this_obj_conv);
17401 }
17402
17403 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
17404         LDKNodeFeatures this_obj_conv;
17405         this_obj_conv.inner = (void*)(this_obj & (~1));
17406         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17407         NodeFeatures_free(this_obj_conv);
17408 }
17409
17410 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
17411         LDKChannelFeatures this_obj_conv;
17412         this_obj_conv.inner = (void*)(this_obj & (~1));
17413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17414         ChannelFeatures_free(this_obj_conv);
17415 }
17416
17417 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
17418         LDKInitFeatures ret_var = InitFeatures_empty();
17419         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17420         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17421         long ret_ref = (long)ret_var.inner;
17422         if (ret_var.is_owned) {
17423                 ret_ref |= 1;
17424         }
17425         return ret_ref;
17426 }
17427
17428 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
17429         LDKInitFeatures ret_var = InitFeatures_known();
17430         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17431         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17432         long ret_ref = (long)ret_var.inner;
17433         if (ret_var.is_owned) {
17434                 ret_ref |= 1;
17435         }
17436         return ret_ref;
17437 }
17438
17439 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
17440         LDKNodeFeatures ret_var = NodeFeatures_empty();
17441         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17442         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17443         long ret_ref = (long)ret_var.inner;
17444         if (ret_var.is_owned) {
17445                 ret_ref |= 1;
17446         }
17447         return ret_ref;
17448 }
17449
17450 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
17451         LDKNodeFeatures ret_var = NodeFeatures_known();
17452         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17453         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17454         long ret_ref = (long)ret_var.inner;
17455         if (ret_var.is_owned) {
17456                 ret_ref |= 1;
17457         }
17458         return ret_ref;
17459 }
17460
17461 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
17462         LDKChannelFeatures ret_var = ChannelFeatures_empty();
17463         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17464         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17465         long ret_ref = (long)ret_var.inner;
17466         if (ret_var.is_owned) {
17467                 ret_ref |= 1;
17468         }
17469         return ret_ref;
17470 }
17471
17472 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
17473         LDKChannelFeatures ret_var = ChannelFeatures_known();
17474         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17475         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17476         long ret_ref = (long)ret_var.inner;
17477         if (ret_var.is_owned) {
17478                 ret_ref |= 1;
17479         }
17480         return ret_ref;
17481 }
17482
17483 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
17484         LDKInitFeatures obj_conv;
17485         obj_conv.inner = (void*)(obj & (~1));
17486         obj_conv.is_owned = false;
17487         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
17488         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17489         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17490         CVec_u8Z_free(ret_var);
17491         return ret_arr;
17492 }
17493
17494 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
17495         LDKNodeFeatures obj_conv;
17496         obj_conv.inner = (void*)(obj & (~1));
17497         obj_conv.is_owned = false;
17498         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
17499         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17500         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17501         CVec_u8Z_free(ret_var);
17502         return ret_arr;
17503 }
17504
17505 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
17506         LDKChannelFeatures obj_conv;
17507         obj_conv.inner = (void*)(obj & (~1));
17508         obj_conv.is_owned = false;
17509         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
17510         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17511         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17512         CVec_u8Z_free(ret_var);
17513         return ret_arr;
17514 }
17515
17516 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
17517         LDKu8slice ser_ref;
17518         ser_ref.datalen = *((uint32_t*)ser);
17519         ser_ref.data = (int8_t*)(ser + 4);
17520         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17521         *ret_conv = InitFeatures_read(ser_ref);
17522         return (long)ret_conv;
17523 }
17524
17525 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
17526         LDKu8slice ser_ref;
17527         ser_ref.datalen = *((uint32_t*)ser);
17528         ser_ref.data = (int8_t*)(ser + 4);
17529         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17530         *ret_conv = NodeFeatures_read(ser_ref);
17531         return (long)ret_conv;
17532 }
17533
17534 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
17535         LDKu8slice ser_ref;
17536         ser_ref.datalen = *((uint32_t*)ser);
17537         ser_ref.data = (int8_t*)(ser + 4);
17538         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17539         *ret_conv = ChannelFeatures_read(ser_ref);
17540         return (long)ret_conv;
17541 }
17542
17543 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
17544         LDKRouteHop this_obj_conv;
17545         this_obj_conv.inner = (void*)(this_obj & (~1));
17546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17547         RouteHop_free(this_obj_conv);
17548 }
17549
17550 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
17551         LDKRouteHop this_ptr_conv;
17552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17553         this_ptr_conv.is_owned = false;
17554         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17555         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
17556         return ret_arr;
17557 }
17558
17559 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
17560         LDKRouteHop this_ptr_conv;
17561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17562         this_ptr_conv.is_owned = false;
17563         LDKPublicKey val_ref;
17564         CHECK(*((uint32_t*)val) == 33);
17565         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17566         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
17567 }
17568
17569 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
17570         LDKRouteHop this_ptr_conv;
17571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17572         this_ptr_conv.is_owned = false;
17573         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
17574         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17575         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17576         long ret_ref = (long)ret_var.inner;
17577         if (ret_var.is_owned) {
17578                 ret_ref |= 1;
17579         }
17580         return ret_ref;
17581 }
17582
17583 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
17584         LDKRouteHop this_ptr_conv;
17585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17586         this_ptr_conv.is_owned = false;
17587         LDKNodeFeatures val_conv;
17588         val_conv.inner = (void*)(val & (~1));
17589         val_conv.is_owned = (val & 1) || (val == 0);
17590         val_conv = NodeFeatures_clone(&val_conv);
17591         RouteHop_set_node_features(&this_ptr_conv, val_conv);
17592 }
17593
17594 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
17595         LDKRouteHop this_ptr_conv;
17596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17597         this_ptr_conv.is_owned = false;
17598         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
17599         return ret_val;
17600 }
17601
17602 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17603         LDKRouteHop this_ptr_conv;
17604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17605         this_ptr_conv.is_owned = false;
17606         RouteHop_set_short_channel_id(&this_ptr_conv, val);
17607 }
17608
17609 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
17610         LDKRouteHop this_ptr_conv;
17611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17612         this_ptr_conv.is_owned = false;
17613         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
17614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17616         long ret_ref = (long)ret_var.inner;
17617         if (ret_var.is_owned) {
17618                 ret_ref |= 1;
17619         }
17620         return ret_ref;
17621 }
17622
17623 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
17624         LDKRouteHop this_ptr_conv;
17625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17626         this_ptr_conv.is_owned = false;
17627         LDKChannelFeatures val_conv;
17628         val_conv.inner = (void*)(val & (~1));
17629         val_conv.is_owned = (val & 1) || (val == 0);
17630         val_conv = ChannelFeatures_clone(&val_conv);
17631         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
17632 }
17633
17634 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
17635         LDKRouteHop this_ptr_conv;
17636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17637         this_ptr_conv.is_owned = false;
17638         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
17639         return ret_val;
17640 }
17641
17642 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
17643         LDKRouteHop this_ptr_conv;
17644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17645         this_ptr_conv.is_owned = false;
17646         RouteHop_set_fee_msat(&this_ptr_conv, val);
17647 }
17648
17649 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
17650         LDKRouteHop this_ptr_conv;
17651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17652         this_ptr_conv.is_owned = false;
17653         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
17654         return ret_val;
17655 }
17656
17657 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
17658         LDKRouteHop this_ptr_conv;
17659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17660         this_ptr_conv.is_owned = false;
17661         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
17662 }
17663
17664 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) {
17665         LDKPublicKey pubkey_arg_ref;
17666         CHECK(*((uint32_t*)pubkey_arg) == 33);
17667         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
17668         LDKNodeFeatures node_features_arg_conv;
17669         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
17670         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
17671         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
17672         LDKChannelFeatures channel_features_arg_conv;
17673         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
17674         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
17675         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
17676         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);
17677         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17678         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17679         long ret_ref = (long)ret_var.inner;
17680         if (ret_var.is_owned) {
17681                 ret_ref |= 1;
17682         }
17683         return ret_ref;
17684 }
17685
17686 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
17687         LDKRouteHop orig_conv;
17688         orig_conv.inner = (void*)(orig & (~1));
17689         orig_conv.is_owned = false;
17690         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
17691         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17692         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17693         long ret_ref = (long)ret_var.inner;
17694         if (ret_var.is_owned) {
17695                 ret_ref |= 1;
17696         }
17697         return ret_ref;
17698 }
17699
17700 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
17701         LDKRoute this_obj_conv;
17702         this_obj_conv.inner = (void*)(this_obj & (~1));
17703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17704         Route_free(this_obj_conv);
17705 }
17706
17707 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
17708         LDKRoute this_ptr_conv;
17709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17710         this_ptr_conv.is_owned = false;
17711         LDKCVec_CVec_RouteHopZZ val_constr;
17712         val_constr.datalen = *((uint32_t*)val);
17713         if (val_constr.datalen > 0)
17714                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17715         else
17716                 val_constr.data = NULL;
17717         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
17718         for (size_t m = 0; m < val_constr.datalen; m++) {
17719                 uint32_tArray val_conv_12 = val_vals[m];
17720                 LDKCVec_RouteHopZ val_conv_12_constr;
17721                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
17722                 if (val_conv_12_constr.datalen > 0)
17723                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17724                 else
17725                         val_conv_12_constr.data = NULL;
17726                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
17727                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
17728                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
17729                         LDKRouteHop val_conv_12_conv_10_conv;
17730                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
17731                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
17732                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
17733                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
17734                 }
17735                 val_constr.data[m] = val_conv_12_constr;
17736         }
17737         Route_set_paths(&this_ptr_conv, val_constr);
17738 }
17739
17740 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
17741         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
17742         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
17743         if (paths_arg_constr.datalen > 0)
17744                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17745         else
17746                 paths_arg_constr.data = NULL;
17747         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
17748         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
17749                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
17750                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
17751                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
17752                 if (paths_arg_conv_12_constr.datalen > 0)
17753                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17754                 else
17755                         paths_arg_conv_12_constr.data = NULL;
17756                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
17757                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
17758                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
17759                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
17760                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
17761                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
17762                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
17763                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
17764                 }
17765                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
17766         }
17767         LDKRoute ret_var = Route_new(paths_arg_constr);
17768         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17769         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17770         long ret_ref = (long)ret_var.inner;
17771         if (ret_var.is_owned) {
17772                 ret_ref |= 1;
17773         }
17774         return ret_ref;
17775 }
17776
17777 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
17778         LDKRoute orig_conv;
17779         orig_conv.inner = (void*)(orig & (~1));
17780         orig_conv.is_owned = false;
17781         LDKRoute ret_var = Route_clone(&orig_conv);
17782         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17783         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17784         long ret_ref = (long)ret_var.inner;
17785         if (ret_var.is_owned) {
17786                 ret_ref |= 1;
17787         }
17788         return ret_ref;
17789 }
17790
17791 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
17792         LDKRoute obj_conv;
17793         obj_conv.inner = (void*)(obj & (~1));
17794         obj_conv.is_owned = false;
17795         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
17796         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17797         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17798         CVec_u8Z_free(ret_var);
17799         return ret_arr;
17800 }
17801
17802 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
17803         LDKu8slice ser_ref;
17804         ser_ref.datalen = *((uint32_t*)ser);
17805         ser_ref.data = (int8_t*)(ser + 4);
17806         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17807         *ret_conv = Route_read(ser_ref);
17808         return (long)ret_conv;
17809 }
17810
17811 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
17812         LDKRouteHint this_obj_conv;
17813         this_obj_conv.inner = (void*)(this_obj & (~1));
17814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17815         RouteHint_free(this_obj_conv);
17816 }
17817
17818 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
17819         LDKRouteHint this_ptr_conv;
17820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17821         this_ptr_conv.is_owned = false;
17822         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17823         memcpy((uint8_t*)(ret_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
17824         return ret_arr;
17825 }
17826
17827 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
17828         LDKRouteHint this_ptr_conv;
17829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17830         this_ptr_conv.is_owned = false;
17831         LDKPublicKey val_ref;
17832         CHECK(*((uint32_t*)val) == 33);
17833         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17834         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
17835 }
17836
17837 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
17838         LDKRouteHint this_ptr_conv;
17839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17840         this_ptr_conv.is_owned = false;
17841         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
17842         return ret_val;
17843 }
17844
17845 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17846         LDKRouteHint this_ptr_conv;
17847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17848         this_ptr_conv.is_owned = false;
17849         RouteHint_set_short_channel_id(&this_ptr_conv, val);
17850 }
17851
17852 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
17853         LDKRouteHint this_ptr_conv;
17854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17855         this_ptr_conv.is_owned = false;
17856         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
17857         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17858         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17859         long ret_ref = (long)ret_var.inner;
17860         if (ret_var.is_owned) {
17861                 ret_ref |= 1;
17862         }
17863         return ret_ref;
17864 }
17865
17866 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
17867         LDKRouteHint this_ptr_conv;
17868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17869         this_ptr_conv.is_owned = false;
17870         LDKRoutingFees val_conv;
17871         val_conv.inner = (void*)(val & (~1));
17872         val_conv.is_owned = (val & 1) || (val == 0);
17873         val_conv = RoutingFees_clone(&val_conv);
17874         RouteHint_set_fees(&this_ptr_conv, val_conv);
17875 }
17876
17877 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
17878         LDKRouteHint this_ptr_conv;
17879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17880         this_ptr_conv.is_owned = false;
17881         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
17882         return ret_val;
17883 }
17884
17885 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17886         LDKRouteHint this_ptr_conv;
17887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17888         this_ptr_conv.is_owned = false;
17889         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
17890 }
17891
17892 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
17893         LDKRouteHint orig_conv;
17894         orig_conv.inner = (void*)(orig & (~1));
17895         orig_conv.is_owned = false;
17896         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
17897         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17898         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17899         long ret_ref = (long)ret_var.inner;
17900         if (ret_var.is_owned) {
17901                 ret_ref |= 1;
17902         }
17903         return ret_ref;
17904 }
17905
17906 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
17907         LDKPublicKey our_node_id_ref;
17908         CHECK(*((uint32_t*)our_node_id) == 33);
17909         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
17910         LDKNetworkGraph network_conv;
17911         network_conv.inner = (void*)(network & (~1));
17912         network_conv.is_owned = false;
17913         LDKPublicKey payee_ref;
17914         CHECK(*((uint32_t*)payee) == 33);
17915         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
17916         LDKCVec_ChannelDetailsZ first_hops_constr;
17917         first_hops_constr.datalen = *((uint32_t*)first_hops);
17918         if (first_hops_constr.datalen > 0)
17919                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17920         else
17921                 first_hops_constr.data = NULL;
17922         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
17923         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
17924                 uint32_t first_hops_conv_16 = first_hops_vals[q];
17925                 LDKChannelDetails first_hops_conv_16_conv;
17926                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
17927                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
17928                 first_hops_constr.data[q] = first_hops_conv_16_conv;
17929         }
17930         LDKCVec_RouteHintZ last_hops_constr;
17931         last_hops_constr.datalen = *((uint32_t*)last_hops);
17932         if (last_hops_constr.datalen > 0)
17933                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
17934         else
17935                 last_hops_constr.data = NULL;
17936         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
17937         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
17938                 uint32_t last_hops_conv_11 = last_hops_vals[l];
17939                 LDKRouteHint last_hops_conv_11_conv;
17940                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
17941                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
17942                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
17943                 last_hops_constr.data[l] = last_hops_conv_11_conv;
17944         }
17945         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17946         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17947         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
17948         FREE(first_hops_constr.data);
17949         return (long)ret_conv;
17950 }
17951
17952 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
17953         LDKNetworkGraph this_obj_conv;
17954         this_obj_conv.inner = (void*)(this_obj & (~1));
17955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17956         NetworkGraph_free(this_obj_conv);
17957 }
17958
17959 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
17960         LDKNetworkGraph orig_conv;
17961         orig_conv.inner = (void*)(orig & (~1));
17962         orig_conv.is_owned = false;
17963         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
17964         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17965         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17966         long ret_ref = (long)ret_var.inner;
17967         if (ret_var.is_owned) {
17968                 ret_ref |= 1;
17969         }
17970         return ret_ref;
17971 }
17972
17973 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
17974         LDKLockedNetworkGraph this_obj_conv;
17975         this_obj_conv.inner = (void*)(this_obj & (~1));
17976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17977         LockedNetworkGraph_free(this_obj_conv);
17978 }
17979
17980 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
17981         LDKNetGraphMsgHandler this_obj_conv;
17982         this_obj_conv.inner = (void*)(this_obj & (~1));
17983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17984         NetGraphMsgHandler_free(this_obj_conv);
17985 }
17986
17987 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
17988         LDKThirtyTwoBytes genesis_hash_ref;
17989         CHECK(*((uint32_t*)genesis_hash) == 32);
17990         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
17991         LDKAccess *chain_access_conv_ptr = NULL;
17992         if (chain_access != 0) {
17993                 LDKAccess chain_access_conv;
17994                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
17995                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
17996                 *chain_access_conv_ptr = chain_access_conv;
17997         }
17998         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17999         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
18000         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18001         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18002         long ret_ref = (long)ret_var.inner;
18003         if (ret_var.is_owned) {
18004                 ret_ref |= 1;
18005         }
18006         return ret_ref;
18007 }
18008
18009 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
18010         LDKAccess *chain_access_conv_ptr = NULL;
18011         if (chain_access != 0) {
18012                 LDKAccess chain_access_conv;
18013                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18014                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18015                 *chain_access_conv_ptr = chain_access_conv;
18016         }
18017         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18018         LDKNetworkGraph network_graph_conv;
18019         network_graph_conv.inner = (void*)(network_graph & (~1));
18020         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
18021         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
18022         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
18023         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18024         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18025         long ret_ref = (long)ret_var.inner;
18026         if (ret_var.is_owned) {
18027                 ret_ref |= 1;
18028         }
18029         return ret_ref;
18030 }
18031
18032 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
18033         LDKNetGraphMsgHandler this_arg_conv;
18034         this_arg_conv.inner = (void*)(this_arg & (~1));
18035         this_arg_conv.is_owned = false;
18036         LDKAccess *chain_access_conv_ptr = NULL;
18037         if (chain_access != 0) {
18038                 LDKAccess chain_access_conv;
18039                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18040                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18041                 *chain_access_conv_ptr = chain_access_conv;
18042         }
18043         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
18044 }
18045
18046 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
18047         LDKNetGraphMsgHandler this_arg_conv;
18048         this_arg_conv.inner = (void*)(this_arg & (~1));
18049         this_arg_conv.is_owned = false;
18050         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
18051         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18052         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18053         long ret_ref = (long)ret_var.inner;
18054         if (ret_var.is_owned) {
18055                 ret_ref |= 1;
18056         }
18057         return ret_ref;
18058 }
18059
18060 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
18061         LDKLockedNetworkGraph this_arg_conv;
18062         this_arg_conv.inner = (void*)(this_arg & (~1));
18063         this_arg_conv.is_owned = false;
18064         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
18065         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18066         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18067         long ret_ref = (long)ret_var.inner;
18068         if (ret_var.is_owned) {
18069                 ret_ref |= 1;
18070         }
18071         return ret_ref;
18072 }
18073
18074 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18075         LDKNetGraphMsgHandler this_arg_conv;
18076         this_arg_conv.inner = (void*)(this_arg & (~1));
18077         this_arg_conv.is_owned = false;
18078         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18079         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
18080         return (long)ret;
18081 }
18082
18083 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18084         LDKNetGraphMsgHandler this_arg_conv;
18085         this_arg_conv.inner = (void*)(this_arg & (~1));
18086         this_arg_conv.is_owned = false;
18087         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18088         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
18089         return (long)ret;
18090 }
18091
18092 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
18093         LDKDirectionalChannelInfo this_obj_conv;
18094         this_obj_conv.inner = (void*)(this_obj & (~1));
18095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18096         DirectionalChannelInfo_free(this_obj_conv);
18097 }
18098
18099 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
18100         LDKDirectionalChannelInfo this_ptr_conv;
18101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18102         this_ptr_conv.is_owned = false;
18103         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
18104         return ret_val;
18105 }
18106
18107 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
18108         LDKDirectionalChannelInfo this_ptr_conv;
18109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18110         this_ptr_conv.is_owned = false;
18111         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
18112 }
18113
18114 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
18115         LDKDirectionalChannelInfo this_ptr_conv;
18116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18117         this_ptr_conv.is_owned = false;
18118         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
18119         return ret_val;
18120 }
18121
18122 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
18123         LDKDirectionalChannelInfo this_ptr_conv;
18124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18125         this_ptr_conv.is_owned = false;
18126         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
18127 }
18128
18129 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
18130         LDKDirectionalChannelInfo this_ptr_conv;
18131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18132         this_ptr_conv.is_owned = false;
18133         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
18134         return ret_val;
18135 }
18136
18137 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18138         LDKDirectionalChannelInfo this_ptr_conv;
18139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18140         this_ptr_conv.is_owned = false;
18141         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18142 }
18143
18144 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
18145         LDKDirectionalChannelInfo this_ptr_conv;
18146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18147         this_ptr_conv.is_owned = false;
18148         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
18149         return ret_val;
18150 }
18151
18152 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
18153         LDKDirectionalChannelInfo this_ptr_conv;
18154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18155         this_ptr_conv.is_owned = false;
18156         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
18157 }
18158
18159 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
18160         LDKDirectionalChannelInfo this_ptr_conv;
18161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18162         this_ptr_conv.is_owned = false;
18163         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
18164         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18165         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18166         long ret_ref = (long)ret_var.inner;
18167         if (ret_var.is_owned) {
18168                 ret_ref |= 1;
18169         }
18170         return ret_ref;
18171 }
18172
18173 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
18174         LDKDirectionalChannelInfo this_ptr_conv;
18175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18176         this_ptr_conv.is_owned = false;
18177         LDKRoutingFees val_conv;
18178         val_conv.inner = (void*)(val & (~1));
18179         val_conv.is_owned = (val & 1) || (val == 0);
18180         val_conv = RoutingFees_clone(&val_conv);
18181         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
18182 }
18183
18184 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
18185         LDKDirectionalChannelInfo this_ptr_conv;
18186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18187         this_ptr_conv.is_owned = false;
18188         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
18189         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18190         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18191         long ret_ref = (long)ret_var.inner;
18192         if (ret_var.is_owned) {
18193                 ret_ref |= 1;
18194         }
18195         return ret_ref;
18196 }
18197
18198 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
18199         LDKDirectionalChannelInfo this_ptr_conv;
18200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18201         this_ptr_conv.is_owned = false;
18202         LDKChannelUpdate val_conv;
18203         val_conv.inner = (void*)(val & (~1));
18204         val_conv.is_owned = (val & 1) || (val == 0);
18205         val_conv = ChannelUpdate_clone(&val_conv);
18206         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
18207 }
18208
18209 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
18210         LDKDirectionalChannelInfo orig_conv;
18211         orig_conv.inner = (void*)(orig & (~1));
18212         orig_conv.is_owned = false;
18213         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
18214         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18215         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18216         long ret_ref = (long)ret_var.inner;
18217         if (ret_var.is_owned) {
18218                 ret_ref |= 1;
18219         }
18220         return ret_ref;
18221 }
18222
18223 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
18224         LDKDirectionalChannelInfo obj_conv;
18225         obj_conv.inner = (void*)(obj & (~1));
18226         obj_conv.is_owned = false;
18227         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
18228         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18229         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18230         CVec_u8Z_free(ret_var);
18231         return ret_arr;
18232 }
18233
18234 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
18235         LDKu8slice ser_ref;
18236         ser_ref.datalen = *((uint32_t*)ser);
18237         ser_ref.data = (int8_t*)(ser + 4);
18238         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
18239         *ret_conv = DirectionalChannelInfo_read(ser_ref);
18240         return (long)ret_conv;
18241 }
18242
18243 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
18244         LDKChannelInfo this_obj_conv;
18245         this_obj_conv.inner = (void*)(this_obj & (~1));
18246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18247         ChannelInfo_free(this_obj_conv);
18248 }
18249
18250 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
18251         LDKChannelInfo this_ptr_conv;
18252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18253         this_ptr_conv.is_owned = false;
18254         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
18255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18257         long ret_ref = (long)ret_var.inner;
18258         if (ret_var.is_owned) {
18259                 ret_ref |= 1;
18260         }
18261         return ret_ref;
18262 }
18263
18264 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
18265         LDKChannelInfo this_ptr_conv;
18266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18267         this_ptr_conv.is_owned = false;
18268         LDKChannelFeatures val_conv;
18269         val_conv.inner = (void*)(val & (~1));
18270         val_conv.is_owned = (val & 1) || (val == 0);
18271         val_conv = ChannelFeatures_clone(&val_conv);
18272         ChannelInfo_set_features(&this_ptr_conv, val_conv);
18273 }
18274
18275 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
18276         LDKChannelInfo this_ptr_conv;
18277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18278         this_ptr_conv.is_owned = false;
18279         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18280         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
18281         return ret_arr;
18282 }
18283
18284 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
18285         LDKChannelInfo this_ptr_conv;
18286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18287         this_ptr_conv.is_owned = false;
18288         LDKPublicKey val_ref;
18289         CHECK(*((uint32_t*)val) == 33);
18290         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18291         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
18292 }
18293
18294 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
18295         LDKChannelInfo this_ptr_conv;
18296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18297         this_ptr_conv.is_owned = false;
18298         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
18299         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18300         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18301         long ret_ref = (long)ret_var.inner;
18302         if (ret_var.is_owned) {
18303                 ret_ref |= 1;
18304         }
18305         return ret_ref;
18306 }
18307
18308 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
18309         LDKChannelInfo this_ptr_conv;
18310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18311         this_ptr_conv.is_owned = false;
18312         LDKDirectionalChannelInfo val_conv;
18313         val_conv.inner = (void*)(val & (~1));
18314         val_conv.is_owned = (val & 1) || (val == 0);
18315         val_conv = DirectionalChannelInfo_clone(&val_conv);
18316         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
18317 }
18318
18319 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
18320         LDKChannelInfo this_ptr_conv;
18321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18322         this_ptr_conv.is_owned = false;
18323         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18324         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
18325         return ret_arr;
18326 }
18327
18328 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
18329         LDKChannelInfo this_ptr_conv;
18330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18331         this_ptr_conv.is_owned = false;
18332         LDKPublicKey val_ref;
18333         CHECK(*((uint32_t*)val) == 33);
18334         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18335         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
18336 }
18337
18338 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
18339         LDKChannelInfo this_ptr_conv;
18340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18341         this_ptr_conv.is_owned = false;
18342         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
18343         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18344         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18345         long ret_ref = (long)ret_var.inner;
18346         if (ret_var.is_owned) {
18347                 ret_ref |= 1;
18348         }
18349         return ret_ref;
18350 }
18351
18352 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
18353         LDKChannelInfo this_ptr_conv;
18354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18355         this_ptr_conv.is_owned = false;
18356         LDKDirectionalChannelInfo val_conv;
18357         val_conv.inner = (void*)(val & (~1));
18358         val_conv.is_owned = (val & 1) || (val == 0);
18359         val_conv = DirectionalChannelInfo_clone(&val_conv);
18360         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
18361 }
18362
18363 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
18364         LDKChannelInfo this_ptr_conv;
18365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18366         this_ptr_conv.is_owned = false;
18367         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
18368         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18369         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18370         long ret_ref = (long)ret_var.inner;
18371         if (ret_var.is_owned) {
18372                 ret_ref |= 1;
18373         }
18374         return ret_ref;
18375 }
18376
18377 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
18378         LDKChannelInfo this_ptr_conv;
18379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18380         this_ptr_conv.is_owned = false;
18381         LDKChannelAnnouncement val_conv;
18382         val_conv.inner = (void*)(val & (~1));
18383         val_conv.is_owned = (val & 1) || (val == 0);
18384         val_conv = ChannelAnnouncement_clone(&val_conv);
18385         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
18386 }
18387
18388 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
18389         LDKChannelInfo orig_conv;
18390         orig_conv.inner = (void*)(orig & (~1));
18391         orig_conv.is_owned = false;
18392         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
18393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18395         long ret_ref = (long)ret_var.inner;
18396         if (ret_var.is_owned) {
18397                 ret_ref |= 1;
18398         }
18399         return ret_ref;
18400 }
18401
18402 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
18403         LDKChannelInfo obj_conv;
18404         obj_conv.inner = (void*)(obj & (~1));
18405         obj_conv.is_owned = false;
18406         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
18407         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18408         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18409         CVec_u8Z_free(ret_var);
18410         return ret_arr;
18411 }
18412
18413 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
18414         LDKu8slice ser_ref;
18415         ser_ref.datalen = *((uint32_t*)ser);
18416         ser_ref.data = (int8_t*)(ser + 4);
18417         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18418         *ret_conv = ChannelInfo_read(ser_ref);
18419         return (long)ret_conv;
18420 }
18421
18422 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
18423         LDKRoutingFees this_obj_conv;
18424         this_obj_conv.inner = (void*)(this_obj & (~1));
18425         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18426         RoutingFees_free(this_obj_conv);
18427 }
18428
18429 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
18430         LDKRoutingFees this_ptr_conv;
18431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18432         this_ptr_conv.is_owned = false;
18433         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
18434         return ret_val;
18435 }
18436
18437 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
18438         LDKRoutingFees this_ptr_conv;
18439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18440         this_ptr_conv.is_owned = false;
18441         RoutingFees_set_base_msat(&this_ptr_conv, val);
18442 }
18443
18444 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
18445         LDKRoutingFees this_ptr_conv;
18446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18447         this_ptr_conv.is_owned = false;
18448         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
18449         return ret_val;
18450 }
18451
18452 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
18453         LDKRoutingFees this_ptr_conv;
18454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18455         this_ptr_conv.is_owned = false;
18456         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
18457 }
18458
18459 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
18460         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
18461         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18462         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18463         long ret_ref = (long)ret_var.inner;
18464         if (ret_var.is_owned) {
18465                 ret_ref |= 1;
18466         }
18467         return ret_ref;
18468 }
18469
18470 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
18471         LDKRoutingFees orig_conv;
18472         orig_conv.inner = (void*)(orig & (~1));
18473         orig_conv.is_owned = false;
18474         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
18475         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18476         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18477         long ret_ref = (long)ret_var.inner;
18478         if (ret_var.is_owned) {
18479                 ret_ref |= 1;
18480         }
18481         return ret_ref;
18482 }
18483
18484 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
18485         LDKu8slice ser_ref;
18486         ser_ref.datalen = *((uint32_t*)ser);
18487         ser_ref.data = (int8_t*)(ser + 4);
18488         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18489         *ret_conv = RoutingFees_read(ser_ref);
18490         return (long)ret_conv;
18491 }
18492
18493 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
18494         LDKRoutingFees obj_conv;
18495         obj_conv.inner = (void*)(obj & (~1));
18496         obj_conv.is_owned = false;
18497         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
18498         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18499         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18500         CVec_u8Z_free(ret_var);
18501         return ret_arr;
18502 }
18503
18504 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
18505         LDKNodeAnnouncementInfo this_obj_conv;
18506         this_obj_conv.inner = (void*)(this_obj & (~1));
18507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18508         NodeAnnouncementInfo_free(this_obj_conv);
18509 }
18510
18511 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
18512         LDKNodeAnnouncementInfo this_ptr_conv;
18513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18514         this_ptr_conv.is_owned = false;
18515         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
18516         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18517         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18518         long ret_ref = (long)ret_var.inner;
18519         if (ret_var.is_owned) {
18520                 ret_ref |= 1;
18521         }
18522         return ret_ref;
18523 }
18524
18525 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
18526         LDKNodeAnnouncementInfo this_ptr_conv;
18527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18528         this_ptr_conv.is_owned = false;
18529         LDKNodeFeatures val_conv;
18530         val_conv.inner = (void*)(val & (~1));
18531         val_conv.is_owned = (val & 1) || (val == 0);
18532         val_conv = NodeFeatures_clone(&val_conv);
18533         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
18534 }
18535
18536 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
18537         LDKNodeAnnouncementInfo this_ptr_conv;
18538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18539         this_ptr_conv.is_owned = false;
18540         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
18541         return ret_val;
18542 }
18543
18544 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
18545         LDKNodeAnnouncementInfo this_ptr_conv;
18546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18547         this_ptr_conv.is_owned = false;
18548         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
18549 }
18550
18551 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
18552         LDKNodeAnnouncementInfo this_ptr_conv;
18553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18554         this_ptr_conv.is_owned = false;
18555         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
18556         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
18557         return ret_arr;
18558 }
18559
18560 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
18561         LDKNodeAnnouncementInfo this_ptr_conv;
18562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18563         this_ptr_conv.is_owned = false;
18564         LDKThreeBytes val_ref;
18565         CHECK(*((uint32_t*)val) == 3);
18566         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
18567         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
18568 }
18569
18570 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
18571         LDKNodeAnnouncementInfo this_ptr_conv;
18572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18573         this_ptr_conv.is_owned = false;
18574         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18575         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
18576         return ret_arr;
18577 }
18578
18579 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
18580         LDKNodeAnnouncementInfo this_ptr_conv;
18581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18582         this_ptr_conv.is_owned = false;
18583         LDKThirtyTwoBytes val_ref;
18584         CHECK(*((uint32_t*)val) == 32);
18585         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18586         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
18587 }
18588
18589 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
18590         LDKNodeAnnouncementInfo this_ptr_conv;
18591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18592         this_ptr_conv.is_owned = false;
18593         LDKCVec_NetAddressZ val_constr;
18594         val_constr.datalen = *((uint32_t*)val);
18595         if (val_constr.datalen > 0)
18596                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18597         else
18598                 val_constr.data = NULL;
18599         uint32_t* val_vals = (uint32_t*)(val + 4);
18600         for (size_t m = 0; m < val_constr.datalen; m++) {
18601                 uint32_t val_conv_12 = val_vals[m];
18602                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18603                 FREE((void*)val_conv_12);
18604                 val_constr.data[m] = val_conv_12_conv;
18605         }
18606         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
18607 }
18608
18609 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
18610         LDKNodeAnnouncementInfo this_ptr_conv;
18611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18612         this_ptr_conv.is_owned = false;
18613         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
18614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18616         long ret_ref = (long)ret_var.inner;
18617         if (ret_var.is_owned) {
18618                 ret_ref |= 1;
18619         }
18620         return ret_ref;
18621 }
18622
18623 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
18624         LDKNodeAnnouncementInfo this_ptr_conv;
18625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18626         this_ptr_conv.is_owned = false;
18627         LDKNodeAnnouncement val_conv;
18628         val_conv.inner = (void*)(val & (~1));
18629         val_conv.is_owned = (val & 1) || (val == 0);
18630         val_conv = NodeAnnouncement_clone(&val_conv);
18631         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
18632 }
18633
18634 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) {
18635         LDKNodeFeatures features_arg_conv;
18636         features_arg_conv.inner = (void*)(features_arg & (~1));
18637         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18638         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
18639         LDKThreeBytes rgb_arg_ref;
18640         CHECK(*((uint32_t*)rgb_arg) == 3);
18641         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
18642         LDKThirtyTwoBytes alias_arg_ref;
18643         CHECK(*((uint32_t*)alias_arg) == 32);
18644         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
18645         LDKCVec_NetAddressZ addresses_arg_constr;
18646         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
18647         if (addresses_arg_constr.datalen > 0)
18648                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18649         else
18650                 addresses_arg_constr.data = NULL;
18651         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
18652         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
18653                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
18654                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
18655                 FREE((void*)addresses_arg_conv_12);
18656                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
18657         }
18658         LDKNodeAnnouncement announcement_message_arg_conv;
18659         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
18660         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
18661         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
18662         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
18663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18665         long ret_ref = (long)ret_var.inner;
18666         if (ret_var.is_owned) {
18667                 ret_ref |= 1;
18668         }
18669         return ret_ref;
18670 }
18671
18672 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
18673         LDKNodeAnnouncementInfo orig_conv;
18674         orig_conv.inner = (void*)(orig & (~1));
18675         orig_conv.is_owned = false;
18676         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
18677         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18678         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18679         long ret_ref = (long)ret_var.inner;
18680         if (ret_var.is_owned) {
18681                 ret_ref |= 1;
18682         }
18683         return ret_ref;
18684 }
18685
18686 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
18687         LDKNodeAnnouncementInfo obj_conv;
18688         obj_conv.inner = (void*)(obj & (~1));
18689         obj_conv.is_owned = false;
18690         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
18691         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18692         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18693         CVec_u8Z_free(ret_var);
18694         return ret_arr;
18695 }
18696
18697 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
18698         LDKu8slice ser_ref;
18699         ser_ref.datalen = *((uint32_t*)ser);
18700         ser_ref.data = (int8_t*)(ser + 4);
18701         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18702         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
18703         return (long)ret_conv;
18704 }
18705
18706 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
18707         LDKNodeInfo this_obj_conv;
18708         this_obj_conv.inner = (void*)(this_obj & (~1));
18709         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18710         NodeInfo_free(this_obj_conv);
18711 }
18712
18713 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
18714         LDKNodeInfo this_ptr_conv;
18715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18716         this_ptr_conv.is_owned = false;
18717         LDKCVec_u64Z val_constr;
18718         val_constr.datalen = *((uint32_t*)val);
18719         if (val_constr.datalen > 0)
18720                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18721         else
18722                 val_constr.data = NULL;
18723         int64_t* val_vals = (int64_t*)(val + 4);
18724         for (size_t i = 0; i < val_constr.datalen; i++) {
18725                 int64_t val_conv_8 = val_vals[i];
18726                 val_constr.data[i] = val_conv_8;
18727         }
18728         NodeInfo_set_channels(&this_ptr_conv, val_constr);
18729 }
18730
18731 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
18732         LDKNodeInfo this_ptr_conv;
18733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18734         this_ptr_conv.is_owned = false;
18735         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
18736         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18737         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18738         long ret_ref = (long)ret_var.inner;
18739         if (ret_var.is_owned) {
18740                 ret_ref |= 1;
18741         }
18742         return ret_ref;
18743 }
18744
18745 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
18746         LDKNodeInfo this_ptr_conv;
18747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18748         this_ptr_conv.is_owned = false;
18749         LDKRoutingFees val_conv;
18750         val_conv.inner = (void*)(val & (~1));
18751         val_conv.is_owned = (val & 1) || (val == 0);
18752         val_conv = RoutingFees_clone(&val_conv);
18753         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
18754 }
18755
18756 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
18757         LDKNodeInfo this_ptr_conv;
18758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18759         this_ptr_conv.is_owned = false;
18760         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
18761         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18762         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18763         long ret_ref = (long)ret_var.inner;
18764         if (ret_var.is_owned) {
18765                 ret_ref |= 1;
18766         }
18767         return ret_ref;
18768 }
18769
18770 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
18771         LDKNodeInfo this_ptr_conv;
18772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18773         this_ptr_conv.is_owned = false;
18774         LDKNodeAnnouncementInfo val_conv;
18775         val_conv.inner = (void*)(val & (~1));
18776         val_conv.is_owned = (val & 1) || (val == 0);
18777         val_conv = NodeAnnouncementInfo_clone(&val_conv);
18778         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
18779 }
18780
18781 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
18782         LDKCVec_u64Z channels_arg_constr;
18783         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
18784         if (channels_arg_constr.datalen > 0)
18785                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18786         else
18787                 channels_arg_constr.data = NULL;
18788         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
18789         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
18790                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
18791                 channels_arg_constr.data[i] = channels_arg_conv_8;
18792         }
18793         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
18794         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
18795         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
18796         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
18797         LDKNodeAnnouncementInfo announcement_info_arg_conv;
18798         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
18799         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
18800         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
18801         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
18802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18804         long ret_ref = (long)ret_var.inner;
18805         if (ret_var.is_owned) {
18806                 ret_ref |= 1;
18807         }
18808         return ret_ref;
18809 }
18810
18811 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
18812         LDKNodeInfo orig_conv;
18813         orig_conv.inner = (void*)(orig & (~1));
18814         orig_conv.is_owned = false;
18815         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
18816         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18817         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18818         long ret_ref = (long)ret_var.inner;
18819         if (ret_var.is_owned) {
18820                 ret_ref |= 1;
18821         }
18822         return ret_ref;
18823 }
18824
18825 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
18826         LDKNodeInfo obj_conv;
18827         obj_conv.inner = (void*)(obj & (~1));
18828         obj_conv.is_owned = false;
18829         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
18830         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18831         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18832         CVec_u8Z_free(ret_var);
18833         return ret_arr;
18834 }
18835
18836 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
18837         LDKu8slice ser_ref;
18838         ser_ref.datalen = *((uint32_t*)ser);
18839         ser_ref.data = (int8_t*)(ser + 4);
18840         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18841         *ret_conv = NodeInfo_read(ser_ref);
18842         return (long)ret_conv;
18843 }
18844
18845 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
18846         LDKNetworkGraph obj_conv;
18847         obj_conv.inner = (void*)(obj & (~1));
18848         obj_conv.is_owned = false;
18849         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
18850         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18851         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18852         CVec_u8Z_free(ret_var);
18853         return ret_arr;
18854 }
18855
18856 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
18857         LDKu8slice ser_ref;
18858         ser_ref.datalen = *((uint32_t*)ser);
18859         ser_ref.data = (int8_t*)(ser + 4);
18860         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18861         *ret_conv = NetworkGraph_read(ser_ref);
18862         return (long)ret_conv;
18863 }
18864
18865 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
18866         LDKThirtyTwoBytes genesis_hash_ref;
18867         CHECK(*((uint32_t*)genesis_hash) == 32);
18868         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
18869         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
18870         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18871         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18872         long ret_ref = (long)ret_var.inner;
18873         if (ret_var.is_owned) {
18874                 ret_ref |= 1;
18875         }
18876         return ret_ref;
18877 }
18878
18879 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
18880         LDKNetworkGraph this_arg_conv;
18881         this_arg_conv.inner = (void*)(this_arg & (~1));
18882         this_arg_conv.is_owned = false;
18883         LDKNodeAnnouncement msg_conv;
18884         msg_conv.inner = (void*)(msg & (~1));
18885         msg_conv.is_owned = false;
18886         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18887         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
18888         return (long)ret_conv;
18889 }
18890
18891 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
18892         LDKNetworkGraph this_arg_conv;
18893         this_arg_conv.inner = (void*)(this_arg & (~1));
18894         this_arg_conv.is_owned = false;
18895         LDKUnsignedNodeAnnouncement msg_conv;
18896         msg_conv.inner = (void*)(msg & (~1));
18897         msg_conv.is_owned = false;
18898         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18899         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
18900         return (long)ret_conv;
18901 }
18902
18903 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
18904         LDKNetworkGraph this_arg_conv;
18905         this_arg_conv.inner = (void*)(this_arg & (~1));
18906         this_arg_conv.is_owned = false;
18907         LDKChannelAnnouncement msg_conv;
18908         msg_conv.inner = (void*)(msg & (~1));
18909         msg_conv.is_owned = false;
18910         LDKAccess *chain_access_conv_ptr = NULL;
18911         if (chain_access != 0) {
18912                 LDKAccess chain_access_conv;
18913                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18914                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18915                 *chain_access_conv_ptr = chain_access_conv;
18916         }
18917         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18918         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
18919         return (long)ret_conv;
18920 }
18921
18922 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
18923         LDKNetworkGraph this_arg_conv;
18924         this_arg_conv.inner = (void*)(this_arg & (~1));
18925         this_arg_conv.is_owned = false;
18926         LDKUnsignedChannelAnnouncement msg_conv;
18927         msg_conv.inner = (void*)(msg & (~1));
18928         msg_conv.is_owned = false;
18929         LDKAccess *chain_access_conv_ptr = NULL;
18930         if (chain_access != 0) {
18931                 LDKAccess chain_access_conv;
18932                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18933                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18934                 *chain_access_conv_ptr = chain_access_conv;
18935         }
18936         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18937         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
18938         return (long)ret_conv;
18939 }
18940
18941 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
18942         LDKNetworkGraph this_arg_conv;
18943         this_arg_conv.inner = (void*)(this_arg & (~1));
18944         this_arg_conv.is_owned = false;
18945         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
18946 }
18947
18948 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
18949         LDKNetworkGraph this_arg_conv;
18950         this_arg_conv.inner = (void*)(this_arg & (~1));
18951         this_arg_conv.is_owned = false;
18952         LDKChannelUpdate msg_conv;
18953         msg_conv.inner = (void*)(msg & (~1));
18954         msg_conv.is_owned = false;
18955         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18956         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
18957         return (long)ret_conv;
18958 }
18959
18960 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
18961         LDKNetworkGraph this_arg_conv;
18962         this_arg_conv.inner = (void*)(this_arg & (~1));
18963         this_arg_conv.is_owned = false;
18964         LDKUnsignedChannelUpdate msg_conv;
18965         msg_conv.inner = (void*)(msg & (~1));
18966         msg_conv.is_owned = false;
18967         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18968         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
18969         return (long)ret_conv;
18970 }
18971