Merge pull request #9 from TheBlueMatt/2021-03-cleanup-debug
[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_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
917         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
918 }
919 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
920         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
921         CHECK(val->result_ok);
922         LDKInvoiceFeatures 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_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
929         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(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_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
938         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
939 }
940 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
941         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
942         CHECK(val->result_ok);
943         LDKChannelConfig 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_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
950         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(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_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
959         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
960 }
961 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
962         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
963         CHECK(val->result_ok);
964         LDKDirectionalChannelInfo 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_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
971         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(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_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
980         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
981 }
982 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
983         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
984         CHECK(val->result_ok);
985         LDKChannelInfo 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_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
992         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
1001         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
1002 }
1003 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
1004         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1005         CHECK(val->result_ok);
1006         LDKRoutingFees res_var = (*val->contents.result);
1007         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1008         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1009         long res_ref = (long)res_var.inner & ~1;
1010         return res_ref;
1011 }
1012 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
1013         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
1014         CHECK(!val->result_ok);
1015         LDKDecodeError err_var = (*val->contents.err);
1016         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1017         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1018         long err_ref = (long)err_var.inner & ~1;
1019         return err_ref;
1020 }
1021 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1022         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1023         switch(obj->tag) {
1024                 case LDKNetAddress_IPv4: {
1025                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1026                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1027                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1028                 }
1029                 case LDKNetAddress_IPv6: {
1030                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1031                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1032                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1033                 }
1034                 case LDKNetAddress_OnionV2: {
1035                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1036                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1037                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1038                 }
1039                 case LDKNetAddress_OnionV3: {
1040                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1041                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1042                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1043                 }
1044                 default: abort();
1045         }
1046 }
1047 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1048         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1049         ret->datalen = *((uint32_t*)elems);
1050         if (ret->datalen == 0) {
1051                 ret->data = NULL;
1052         } else {
1053                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1054                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1055                 for (size_t i = 0; i < ret->datalen; i++) {
1056                         uint32_t arr_elem = java_elems[i];
1057                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1058                         FREE((void*)arr_elem);
1059                         ret->data[i] = arr_elem_conv;
1060                 }
1061         }
1062         return (long)ret;
1063 }
1064 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1065         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1066         for (size_t i = 0; i < ret.datalen; i++) {
1067                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1068         }
1069         return ret;
1070 }
1071 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
1072         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
1073 }
1074 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
1075         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1076         CHECK(val->result_ok);
1077         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
1078         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080         long res_ref = (long)res_var.inner & ~1;
1081         return res_ref;
1082 }
1083 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
1084         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
1085         CHECK(!val->result_ok);
1086         LDKDecodeError err_var = (*val->contents.err);
1087         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1088         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1089         long err_ref = (long)err_var.inner & ~1;
1090         return err_ref;
1091 }
1092 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
1093         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1094         ret->datalen = *((uint32_t*)elems);
1095         if (ret->datalen == 0) {
1096                 ret->data = NULL;
1097         } else {
1098                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1099                 int64_t *java_elems = (int64_t*)(elems + 4);
1100                 for (size_t i = 0; i < ret->datalen; i++) {
1101                         ret->data[i] = java_elems[i];
1102                 }
1103         }
1104         return (long)ret;
1105 }
1106 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1107         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1108         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1109         return ret;
1110 }
1111 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
1112         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
1113 }
1114 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
1115         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
1116         CHECK(val->result_ok);
1117         LDKNodeInfo 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_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
1124         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
1133         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
1134 }
1135 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
1136         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1137         CHECK(val->result_ok);
1138         LDKNetworkGraph res_var = (*val->contents.result);
1139         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1140         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1141         long res_ref = (long)res_var.inner & ~1;
1142         return res_ref;
1143 }
1144 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
1145         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
1146         CHECK(!val->result_ok);
1147         LDKDecodeError err_var = (*val->contents.err);
1148         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1149         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1150         long err_ref = (long)err_var.inner & ~1;
1151         return err_ref;
1152 }
1153 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
1154         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1155         ret->a = a;
1156         LDKTransaction b_ref;
1157         b_ref.datalen = *((uint32_t*)b);
1158         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1159         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1160         b_ref.data_is_owned = false;
1161         ret->b = b_ref;
1162         return (long)ret;
1163 }
1164 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
1165         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1166         return tuple->a;
1167 }
1168 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
1169         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1170         LDKTransaction b_var = tuple->b;
1171         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1172         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1173         return b_arr;
1174 }
1175 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
1176         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1177         ret->datalen = *((uint32_t*)elems);
1178         if (ret->datalen == 0) {
1179                 ret->data = NULL;
1180         } else {
1181                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1182                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1183                 for (size_t i = 0; i < ret->datalen; i++) {
1184                         uint32_t arr_elem = java_elems[i];
1185                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1186                         FREE((void*)arr_elem);
1187                         ret->data[i] = arr_elem_conv;
1188                 }
1189         }
1190         return (long)ret;
1191 }
1192 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
1193         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1194 }
1195 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
1196         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1197         CHECK(val->result_ok);
1198         return *val->contents.result;
1199 }
1200 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
1201         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1202         CHECK(!val->result_ok);
1203         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
1204         return err_conv;
1205 }
1206 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
1207         LDKMonitorEvent *obj = (LDKMonitorEvent*)ptr;
1208         switch(obj->tag) {
1209                 case LDKMonitorEvent_HTLCEvent: {
1210                         return 0 /* LDKMonitorEvent - HTLCEvent */;
1211                 }
1212                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1213                         return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */;
1214                 }
1215                 default: abort();
1216         }
1217 }
1218 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
1219         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1220         ret->datalen = *((uint32_t*)elems);
1221         if (ret->datalen == 0) {
1222                 ret->data = NULL;
1223         } else {
1224                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1225                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1226                 for (size_t i = 0; i < ret->datalen; i++) {
1227                         uint32_t arr_elem = java_elems[i];
1228                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1229                         FREE((void*)arr_elem);
1230                         ret->data[i] = arr_elem_conv;
1231                 }
1232         }
1233         return (long)ret;
1234 }
1235 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1236         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1237         for (size_t i = 0; i < ret.datalen; i++) {
1238                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1239         }
1240         return ret;
1241 }
1242 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1243         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
1244         switch(obj->tag) {
1245                 case LDKSpendableOutputDescriptor_StaticOutput: {
1246                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1247                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1248                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1249                         long outpoint_ref = (long)outpoint_var.inner & ~1;
1250                         long output_ref = ((long)&obj->static_output.output) | 1;
1251                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
1252                 }
1253                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1254                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */;
1255                 }
1256                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1257                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */;
1258                 }
1259                 default: abort();
1260         }
1261 }
1262 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1263         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1264         ret->datalen = *((uint32_t*)elems);
1265         if (ret->datalen == 0) {
1266                 ret->data = NULL;
1267         } else {
1268                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1269                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1270                 for (size_t i = 0; i < ret->datalen; i++) {
1271                         uint32_t arr_elem = java_elems[i];
1272                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1273                         FREE((void*)arr_elem);
1274                         ret->data[i] = arr_elem_conv;
1275                 }
1276         }
1277         return (long)ret;
1278 }
1279 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1280         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1281         for (size_t i = 0; i < ret.datalen; i++) {
1282                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1283         }
1284         return ret;
1285 }
1286 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
1287         LDKEvent *obj = (LDKEvent*)ptr;
1288         switch(obj->tag) {
1289                 case LDKEvent_FundingGenerationReady: {
1290                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1291                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
1292                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1293                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1294                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
1295                         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;
1296                 }
1297                 case LDKEvent_FundingBroadcastSafe: {
1298                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
1299                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
1302                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
1303                 }
1304                 case LDKEvent_PaymentReceived: {
1305                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1306                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
1307                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1308                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
1309                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
1310                 }
1311                 case LDKEvent_PaymentSent: {
1312                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1313                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
1314                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
1315                 }
1316                 case LDKEvent_PaymentFailed: {
1317                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1318                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
1319                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
1320                 }
1321                 case LDKEvent_PendingHTLCsForwardable: {
1322                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
1323                 }
1324                 case LDKEvent_SpendableOutputs: {
1325                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1326                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1327                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
1328                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1329                                 long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
1330                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1331                         }
1332                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
1333                 }
1334                 default: abort();
1335         }
1336 }
1337 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
1338         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
1339         ret->datalen = *((uint32_t*)elems);
1340         if (ret->datalen == 0) {
1341                 ret->data = NULL;
1342         } else {
1343                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
1344                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1345                 for (size_t i = 0; i < ret->datalen; i++) {
1346                         uint32_t arr_elem = java_elems[i];
1347                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
1348                         FREE((void*)arr_elem);
1349                         ret->data[i] = arr_elem_conv;
1350                 }
1351         }
1352         return (long)ret;
1353 }
1354 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1355         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1356         for (size_t i = 0; i < ret.datalen; i++) {
1357                 ret.data[i] = Event_clone(&orig->data[i]);
1358         }
1359         return ret;
1360 }
1361 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
1362         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
1363 }
1364 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
1365         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
1366         CHECK(val->result_ok);
1367         LDKOutPoint 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_OutPointDecodeErrorZ_get_err(uint32_t arg) {
1374         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(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_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1383         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
1384 }
1385 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1386         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
1387         CHECK(val->result_ok);
1388         LDKChannelMonitorUpdate 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_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
1395         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(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_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
1404         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
1405 }
1406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
1407         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1408         CHECK(val->result_ok);
1409         LDKHTLCUpdate res_var = (*val->contents.result);
1410         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1411         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1412         long res_ref = (long)res_var.inner & ~1;
1413         return res_ref;
1414 }
1415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
1416         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
1417         CHECK(!val->result_ok);
1418         LDKDecodeError err_var = (*val->contents.err);
1419         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421         long err_ref = (long)err_var.inner & ~1;
1422         return err_ref;
1423 }
1424 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
1425         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
1426 }
1427 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
1428         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1429         CHECK(val->result_ok);
1430         return *val->contents.result;
1431 }
1432 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
1433         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
1434         CHECK(!val->result_ok);
1435         LDKMonitorUpdateError err_var = (*val->contents.err);
1436         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438         long err_ref = (long)err_var.inner & ~1;
1439         return err_ref;
1440 }
1441 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
1442         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
1443         LDKOutPoint a_conv;
1444         a_conv.inner = (void*)(a & (~1));
1445         a_conv.is_owned = (a & 1) || (a == 0);
1446         a_conv = OutPoint_clone(&a_conv);
1447         ret->a = a_conv;
1448         LDKCVec_u8Z b_ref;
1449         b_ref.datalen = *((uint32_t*)b);
1450         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1451         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1452         ret->b = b_ref;
1453         return (long)ret;
1454 }
1455 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
1456         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
1457         LDKOutPoint a_var = tuple->a;
1458         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1459         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1460         long a_ref = (long)a_var.inner & ~1;
1461         return a_ref;
1462 }
1463 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
1464         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(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_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
1471         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
1472         ret->a = a;
1473         LDKCVec_u8Z b_ref;
1474         b_ref.datalen = *((uint32_t*)b);
1475         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
1476         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
1477         ret->b = b_ref;
1478         return (long)ret;
1479 }
1480 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_a(uint32_t ptr) {
1481         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1482         return tuple->a;
1483 }
1484 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_get_b(uint32_t ptr) {
1485         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
1486         LDKCVec_u8Z b_var = tuple->b;
1487         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1488         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
1489         return b_arr;
1490 }
1491 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
1492         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
1493         ret->datalen = *((uint32_t*)elems);
1494         if (ret->datalen == 0) {
1495                 ret->data = NULL;
1496         } else {
1497                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
1498                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1499                 for (size_t i = 0; i < ret->datalen; i++) {
1500                         uint32_t arr_elem = java_elems[i];
1501                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
1502                         FREE((void*)arr_elem);
1503                         ret->data[i] = arr_elem_conv;
1504                 }
1505         }
1506         return (long)ret;
1507 }
1508 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
1509         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
1510         for (size_t i = 0; i < ret.datalen; i++) {
1511                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
1512         }
1513         return ret;
1514 }
1515 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
1516         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
1517         LDKThirtyTwoBytes a_ref;
1518         CHECK(*((uint32_t*)a) == 32);
1519         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1520         ret->a = a_ref;
1521         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
1522         b_constr.datalen = *((uint32_t*)b);
1523         if (b_constr.datalen > 0)
1524                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
1525         else
1526                 b_constr.data = NULL;
1527         uint32_t* b_vals = (uint32_t*)(b + 4);
1528         for (size_t e = 0; e < b_constr.datalen; e++) {
1529                 uint32_t b_conv_30 = b_vals[e];
1530                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
1531                 FREE((void*)b_conv_30);
1532                 b_constr.data[e] = b_conv_30_conv;
1533         }
1534         ret->b = b_constr;
1535         return (long)ret;
1536 }
1537 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t ptr) {
1538         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1539         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1540         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1541         return a_arr;
1542 }
1543 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t ptr) {
1544         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
1545         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
1546         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1547         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1548         for (size_t e = 0; e < b_var.datalen; e++) {
1549                 long b_conv_30_ref = (long)(&b_var.data[e]) | 1;
1550                 b_arr_ptr[e] = b_conv_30_ref;
1551         }
1552         return b_arr;
1553 }
1554 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
1555         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
1556         ret->datalen = *((uint32_t*)elems);
1557         if (ret->datalen == 0) {
1558                 ret->data = NULL;
1559         } else {
1560                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
1561                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1562                 for (size_t i = 0; i < ret->datalen; i++) {
1563                         uint32_t arr_elem = java_elems[i];
1564                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
1565                         FREE((void*)arr_elem);
1566                         ret->data[i] = arr_elem_conv;
1567                 }
1568         }
1569         return (long)ret;
1570 }
1571 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
1572         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1573         ret->a = a;
1574         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
1575         FREE((void*)b);
1576         ret->b = b_conv;
1577         return (long)ret;
1578 }
1579 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
1580         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1581         return tuple->a;
1582 }
1583 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
1584         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
1585         long b_ref = ((long)&tuple->b) | 1;
1586         return (long)b_ref;
1587 }
1588 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
1589         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
1590         ret->datalen = *((uint32_t*)elems);
1591         if (ret->datalen == 0) {
1592                 ret->data = NULL;
1593         } else {
1594                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
1595                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1596                 for (size_t i = 0; i < ret->datalen; i++) {
1597                         uint32_t arr_elem = java_elems[i];
1598                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
1599                         FREE((void*)arr_elem);
1600                         ret->data[i] = arr_elem_conv;
1601                 }
1602         }
1603         return (long)ret;
1604 }
1605 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1606         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1607         for (size_t i = 0; i < ret.datalen; i++) {
1608                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1609         }
1610         return ret;
1611 }
1612 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
1613         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
1614         LDKThirtyTwoBytes a_ref;
1615         CHECK(*((uint32_t*)a) == 32);
1616         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1617         ret->a = a_ref;
1618         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
1619         b_constr.datalen = *((uint32_t*)b);
1620         if (b_constr.datalen > 0)
1621                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
1622         else
1623                 b_constr.data = NULL;
1624         uint32_t* b_vals = (uint32_t*)(b + 4);
1625         for (size_t z = 0; z < b_constr.datalen; z++) {
1626                 uint32_t b_conv_25 = b_vals[z];
1627                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
1628                 FREE((void*)b_conv_25);
1629                 b_constr.data[z] = b_conv_25_conv;
1630         }
1631         ret->b = b_constr;
1632         return (long)ret;
1633 }
1634 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
1635         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1636         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1637         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1638         return a_arr;
1639 }
1640 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
1641         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
1642         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
1643         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1644         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
1645         for (size_t z = 0; z < b_var.datalen; z++) {
1646                 long b_conv_25_ref = (long)(&b_var.data[z]) | 1;
1647                 b_arr_ptr[z] = b_conv_25_ref;
1648         }
1649         return b_arr;
1650 }
1651 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
1652         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
1653         ret->datalen = *((uint32_t*)elems);
1654         if (ret->datalen == 0) {
1655                 ret->data = NULL;
1656         } else {
1657                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
1658                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1659                 for (size_t i = 0; i < ret->datalen; i++) {
1660                         uint32_t arr_elem = java_elems[i];
1661                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
1662                         FREE((void*)arr_elem);
1663                         ret->data[i] = arr_elem_conv;
1664                 }
1665         }
1666         return (long)ret;
1667 }
1668 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1669         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1670         LDKSignature a_ref;
1671         CHECK(*((uint32_t*)a) == 64);
1672         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1673         ret->a = a_ref;
1674         LDKCVec_SignatureZ b_constr;
1675         b_constr.datalen = *((uint32_t*)b);
1676         if (b_constr.datalen > 0)
1677                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1678         else
1679                 b_constr.data = NULL;
1680         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1681         for (size_t m = 0; m < b_constr.datalen; m++) {
1682                 int8_tArray b_conv_12 = b_vals[m];
1683                 LDKSignature b_conv_12_ref;
1684                 CHECK(*((uint32_t*)b_conv_12) == 64);
1685                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1686                 b_constr.data[m] = b_conv_12_ref;
1687         }
1688         ret->b = b_constr;
1689         return (long)ret;
1690 }
1691 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
1692         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1693         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1694         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
1695         return a_arr;
1696 }
1697 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
1698         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
1699         LDKCVec_SignatureZ b_var = tuple->b;
1700         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1701         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
1702         for (size_t m = 0; m < b_var.datalen; m++) {
1703                 int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1704                 memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
1705                 b_arr_ptr[m] = b_conv_12_arr;
1706         }
1707         return b_arr;
1708 }
1709 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1710         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1711 }
1712 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1713         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1714         CHECK(val->result_ok);
1715         long res_ref = (long)(&(*val->contents.result)) | 1;
1716         return res_ref;
1717 }
1718 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1719         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1720         CHECK(!val->result_ok);
1721         return *val->contents.err;
1722 }
1723 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1724         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1725 }
1726 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1727         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1728         CHECK(val->result_ok);
1729         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1730         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1731         return res_arr;
1732 }
1733 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1734         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1735         CHECK(!val->result_ok);
1736         return *val->contents.err;
1737 }
1738 typedef struct LDKSign_JCalls {
1739         atomic_size_t refcnt;
1740         uint32_t get_per_commitment_point_meth;
1741         uint32_t release_commitment_secret_meth;
1742         uint32_t channel_keys_id_meth;
1743         uint32_t sign_counterparty_commitment_meth;
1744         uint32_t sign_holder_commitment_and_htlcs_meth;
1745         uint32_t sign_justice_transaction_meth;
1746         uint32_t sign_counterparty_htlc_transaction_meth;
1747         uint32_t sign_closing_transaction_meth;
1748         uint32_t sign_channel_announcement_meth;
1749         uint32_t ready_channel_meth;
1750         uint32_t write_meth;
1751 } LDKSign_JCalls;
1752 static void LDKSign_JCalls_free(void* this_arg) {
1753         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1754         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1755                 js_free(j_calls->get_per_commitment_point_meth);
1756                 js_free(j_calls->release_commitment_secret_meth);
1757                 js_free(j_calls->channel_keys_id_meth);
1758                 js_free(j_calls->sign_counterparty_commitment_meth);
1759                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1760                 js_free(j_calls->sign_justice_transaction_meth);
1761                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1762                 js_free(j_calls->sign_closing_transaction_meth);
1763                 js_free(j_calls->sign_channel_announcement_meth);
1764                 js_free(j_calls->ready_channel_meth);
1765                 js_free(j_calls->write_meth);
1766                 FREE(j_calls);
1767         }
1768 }
1769 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1770         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1771         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1772         LDKPublicKey ret_ref;
1773         CHECK(*((uint32_t*)ret) == 33);
1774         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1775         return ret_ref;
1776 }
1777 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1778         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1779         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1780         LDKThirtyTwoBytes ret_ref;
1781         CHECK(*((uint32_t*)ret) == 32);
1782         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1783         return ret_ref;
1784 }
1785 LDKThirtyTwoBytes channel_keys_id_jcall(const void* this_arg) {
1786         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1787         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1788         LDKThirtyTwoBytes ret_ref;
1789         CHECK(*((uint32_t*)ret) == 32);
1790         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1791         return ret_ref;
1792 }
1793 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1794         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1795         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1796         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1797         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1798         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1799         long commitment_tx_ref = (long)commitment_tx_var.inner;
1800         if (commitment_tx_var.is_owned) {
1801                 commitment_tx_ref |= 1;
1802         }
1803         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1804         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1805         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
1806         return ret_conv;
1807 }
1808 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1809         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1810         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1811         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1812         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1813         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1814         long commitment_tx_ref = (long)commitment_tx_var.inner;
1815         if (commitment_tx_var.is_owned) {
1816                 commitment_tx_ref |= 1;
1817         }
1818         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1819         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1820         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
1821         return ret_conv;
1822 }
1823 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) {
1824         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1825         LDKTransaction justice_tx_var = justice_tx;
1826         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1827         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1828         Transaction_free(justice_tx_var);
1829         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1830         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
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_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_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_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1845         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1846         LDKTransaction htlc_tx_var = htlc_tx;
1847         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1848         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1849         Transaction_free(htlc_tx_var);
1850         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1851         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1852         LDKHTLCOutputInCommitment htlc_var = *htlc;
1853         htlc_var = HTLCOutputInCommitment_clone(htlc);
1854         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1855         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1856         long htlc_ref = (long)htlc_var.inner;
1857         if (htlc_var.is_owned) {
1858                 htlc_ref |= 1;
1859         }
1860         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);
1861         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1862         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1863         return ret_conv;
1864 }
1865 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1866         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1867         LDKTransaction closing_tx_var = closing_tx;
1868         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1869         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1870         Transaction_free(closing_tx_var);
1871         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1872         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1873         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1874         return ret_conv;
1875 }
1876 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1877         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1878         LDKUnsignedChannelAnnouncement msg_var = *msg;
1879         msg_var = UnsignedChannelAnnouncement_clone(msg);
1880         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1881         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1882         long msg_ref = (long)msg_var.inner;
1883         if (msg_var.is_owned) {
1884                 msg_ref |= 1;
1885         }
1886         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1887         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1888         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1889         return ret_conv;
1890 }
1891 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1892         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1893         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1894         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1895         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1896         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1897         long channel_parameters_ref = (long)channel_parameters_var.inner;
1898         if (channel_parameters_var.is_owned) {
1899                 channel_parameters_ref |= 1;
1900         }
1901         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1902 }
1903 LDKCVec_u8Z write_jcall(const void* this_arg) {
1904         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1905         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1906         LDKCVec_u8Z ret_ref;
1907         ret_ref.datalen = *((uint32_t*)ret);
1908         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1909         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1910         return ret_ref;
1911 }
1912 static void* LDKSign_JCalls_clone(const void* this_arg) {
1913         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1914         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1915         return (void*) this_arg;
1916 }
1917 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1918         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1919         atomic_init(&calls->refcnt, 1);
1920         //TODO: Assign calls->o from o
1921
1922         LDKChannelPublicKeys pubkeys_conv;
1923         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1924         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1925         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1926
1927         LDKSign ret = {
1928                 .this_arg = (void*) calls,
1929                 .get_per_commitment_point = get_per_commitment_point_jcall,
1930                 .release_commitment_secret = release_commitment_secret_jcall,
1931                 .channel_keys_id = channel_keys_id_jcall,
1932                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1933                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
1934                 .sign_justice_transaction = sign_justice_transaction_jcall,
1935                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1936                 .sign_closing_transaction = sign_closing_transaction_jcall,
1937                 .sign_channel_announcement = sign_channel_announcement_jcall,
1938                 .ready_channel = ready_channel_jcall,
1939                 .clone = LDKSign_JCalls_clone,
1940                 .write = write_jcall,
1941                 .free = LDKSign_JCalls_free,
1942                 .pubkeys = pubkeys_conv,
1943                 .set_pubkeys = NULL,
1944         };
1945         return ret;
1946 }
1947 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1948         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
1949         *res_ptr = LDKSign_init(o, pubkeys);
1950         return (long)res_ptr;
1951 }
1952 int8_tArray  __attribute__((visibility("default"))) TS_Sign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1953         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1954         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1955         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1956         return ret_arr;
1957 }
1958
1959 int8_tArray  __attribute__((visibility("default"))) TS_Sign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1960         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1961         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1962         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1963         return ret_arr;
1964 }
1965
1966 int8_tArray  __attribute__((visibility("default"))) TS_Sign_channel_keys_id(uint32_t this_arg) {
1967         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1968         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1969         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1970         return ret_arr;
1971 }
1972
1973 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1974         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1975         LDKCommitmentTransaction commitment_tx_conv;
1976         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1977         commitment_tx_conv.is_owned = false;
1978         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1979         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1980         return (long)ret_conv;
1981 }
1982
1983 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1984         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1985         LDKHolderCommitmentTransaction commitment_tx_conv;
1986         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1987         commitment_tx_conv.is_owned = false;
1988         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1989         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1990         return (long)ret_conv;
1991 }
1992
1993 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) {
1994         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
1995         LDKTransaction justice_tx_ref;
1996         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1997         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1998         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1999         justice_tx_ref.data_is_owned = true;
2000         unsigned char per_commitment_key_arr[32];
2001         CHECK(*((uint32_t*)per_commitment_key) == 32);
2002         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2003         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2004         LDKHTLCOutputInCommitment htlc_conv;
2005         htlc_conv.inner = (void*)(htlc & (~1));
2006         htlc_conv.is_owned = false;
2007         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2008         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2009         return (long)ret_conv;
2010 }
2011
2012 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) {
2013         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2014         LDKTransaction htlc_tx_ref;
2015         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
2016         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2017         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
2018         htlc_tx_ref.data_is_owned = true;
2019         LDKPublicKey per_commitment_point_ref;
2020         CHECK(*((uint32_t*)per_commitment_point) == 33);
2021         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2022         LDKHTLCOutputInCommitment htlc_conv;
2023         htlc_conv.inner = (void*)(htlc & (~1));
2024         htlc_conv.is_owned = false;
2025         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2026         *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);
2027         return (long)ret_conv;
2028 }
2029
2030 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
2031         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2032         LDKTransaction closing_tx_ref;
2033         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
2034         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2035         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
2036         closing_tx_ref.data_is_owned = true;
2037         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2038         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2039         return (long)ret_conv;
2040 }
2041
2042 uint32_t  __attribute__((visibility("default"))) TS_Sign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2043         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2044         LDKUnsignedChannelAnnouncement msg_conv;
2045         msg_conv.inner = (void*)(msg & (~1));
2046         msg_conv.is_owned = false;
2047         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2048         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2049         return (long)ret_conv;
2050 }
2051
2052 void  __attribute__((visibility("default"))) TS_Sign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2053         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2054         LDKChannelTransactionParameters channel_parameters_conv;
2055         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2056         channel_parameters_conv.is_owned = false;
2057         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2058 }
2059
2060 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2061         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2062         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2063         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2064         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2065         CVec_u8Z_free(ret_var);
2066         return ret_arr;
2067 }
2068
2069 LDKChannelPublicKeys LDKSign_set_get_pubkeys(LDKSign* this_arg) {
2070         if (this_arg->set_pubkeys != NULL)
2071                 this_arg->set_pubkeys(this_arg);
2072         return this_arg->pubkeys;
2073 }
2074 uint32_t  __attribute__((visibility("default"))) TS_Sign_get_pubkeys(uint32_t this_arg) {
2075         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2076         LDKChannelPublicKeys ret_var = LDKSign_set_get_pubkeys(this_arg_conv);
2077         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2078         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2079         long ret_ref = (long)ret_var.inner;
2080         if (ret_var.is_owned) {
2081                 ret_ref |= 1;
2082         }
2083         return ret_ref;
2084 }
2085
2086 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2087         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2088         LDKThirtyTwoBytes a_ref;
2089         CHECK(*((uint32_t*)a) == 32);
2090         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2091         ret->a = a_ref;
2092         LDKChannelMonitor b_conv;
2093         b_conv.inner = (void*)(b & (~1));
2094         b_conv.is_owned = (b & 1) || (b == 0);
2095         b_conv = ChannelMonitor_clone(&b_conv);
2096         ret->b = b_conv;
2097         return (long)ret;
2098 }
2099 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
2100         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2101         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2102         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2103         return a_arr;
2104 }
2105 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
2106         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2107         LDKChannelMonitor b_var = tuple->b;
2108         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2109         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2110         long b_ref = (long)b_var.inner & ~1;
2111         return b_ref;
2112 }
2113 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
2114         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
2115 }
2116 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
2117         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2118         CHECK(val->result_ok);
2119         long res_ref = (long)(&(*val->contents.result)) | 1;
2120         return res_ref;
2121 }
2122 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
2123         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
2124         CHECK(!val->result_ok);
2125         LDKDecodeError err_var = (*val->contents.err);
2126         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2127         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2128         long err_ref = (long)err_var.inner & ~1;
2129         return err_ref;
2130 }
2131 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
2132         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
2133 }
2134 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
2135         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2136         CHECK(val->result_ok);
2137         long res_ref = ((long)&(*val->contents.result)) | 1;
2138         return (long)res_ref;
2139 }
2140 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
2141         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
2142         CHECK(!val->result_ok);
2143         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
2144         return err_conv;
2145 }
2146 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2147         LDKAPIError *obj = (LDKAPIError*)ptr;
2148         switch(obj->tag) {
2149                 case LDKAPIError_APIMisuseError: {
2150                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
2151                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2152                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2153                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
2154                 }
2155                 case LDKAPIError_FeeRateTooHigh: {
2156                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
2157                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2158                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2159                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
2160                 }
2161                 case LDKAPIError_RouteError: {
2162                         LDKStr err_str = obj->route_error.err;
2163                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2164                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2165                 }
2166                 case LDKAPIError_ChannelUnavailable: {
2167                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
2168                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2169                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
2170                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
2171                 }
2172                 case LDKAPIError_MonitorUpdateFailed: {
2173                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2174                 }
2175                 default: abort();
2176         }
2177 }
2178 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2179         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2180 }
2181 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2182         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2183         CHECK(val->result_ok);
2184         return *val->contents.result;
2185 }
2186 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2187         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2188         CHECK(!val->result_ok);
2189         long err_ref = ((long)&(*val->contents.err)) | 1;
2190         return err_ref;
2191 }
2192 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2193         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2194         ret->datalen = *((uint32_t*)elems);
2195         if (ret->datalen == 0) {
2196                 ret->data = NULL;
2197         } else {
2198                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2199                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2200                 for (size_t i = 0; i < ret->datalen; i++) {
2201                         uint32_t arr_elem = java_elems[i];
2202                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2203                         FREE((void*)arr_elem);
2204                         ret->data[i] = arr_elem_conv;
2205                 }
2206         }
2207         return (long)ret;
2208 }
2209 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2210         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2211         for (size_t i = 0; i < ret.datalen; i++) {
2212                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2213         }
2214         return ret;
2215 }
2216 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2217         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2218         ret->datalen = *((uint32_t*)elems);
2219         if (ret->datalen == 0) {
2220                 ret->data = NULL;
2221         } else {
2222                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2223                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2224                 for (size_t i = 0; i < ret->datalen; i++) {
2225                         uint32_t arr_elem = java_elems[i];
2226                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2227                         FREE((void*)arr_elem);
2228                         ret->data[i] = arr_elem_conv;
2229                 }
2230         }
2231         return (long)ret;
2232 }
2233 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2234         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2235         for (size_t i = 0; i < ret.datalen; i++) {
2236                 ret.data[i] = APIError_clone(&orig->data[i]);
2237         }
2238         return ret;
2239 }
2240 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
2241         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
2242         ret->datalen = *((uint32_t*)elems);
2243         if (ret->datalen == 0) {
2244                 ret->data = NULL;
2245         } else {
2246                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
2247                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2248                 for (size_t i = 0; i < ret->datalen; i++) {
2249                         uint32_t arr_elem = java_elems[i];
2250                         LDKChannelDetails arr_elem_conv;
2251                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2252                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2253                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
2254                         ret->data[i] = arr_elem_conv;
2255                 }
2256         }
2257         return (long)ret;
2258 }
2259 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2260         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2261         for (size_t i = 0; i < ret.datalen; i++) {
2262                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2263         }
2264         return ret;
2265 }
2266 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2267         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)ptr;
2268         switch(obj->tag) {
2269                 case LDKPaymentSendFailure_ParameterError: {
2270                         return 0 /* LDKPaymentSendFailure - ParameterError */;
2271                 }
2272                 case LDKPaymentSendFailure_PathParameterError: {
2273                         return 0 /* LDKPaymentSendFailure - PathParameterError */;
2274                 }
2275                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2276                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */;
2277                 }
2278                 case LDKPaymentSendFailure_PartialFailure: {
2279                         return 0 /* LDKPaymentSendFailure - PartialFailure */;
2280                 }
2281                 default: abort();
2282         }
2283 }
2284 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2285         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2286 }
2287 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2288         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2289         CHECK(val->result_ok);
2290         return *val->contents.result;
2291 }
2292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2293         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2294         CHECK(!val->result_ok);
2295         long err_ref = ((long)&(*val->contents.err)) | 1;
2296         return err_ref;
2297 }
2298 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2299         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2300         ret->datalen = *((uint32_t*)elems);
2301         if (ret->datalen == 0) {
2302                 ret->data = NULL;
2303         } else {
2304                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2305                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2306                 for (size_t i = 0; i < ret->datalen; i++) {
2307                         uint32_t arr_elem = java_elems[i];
2308                         LDKChannelMonitor arr_elem_conv;
2309                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2310                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2311                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2312                         ret->data[i] = arr_elem_conv;
2313                 }
2314         }
2315         return (long)ret;
2316 }
2317 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2318         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2319         for (size_t i = 0; i < ret.datalen; i++) {
2320                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2321         }
2322         return ret;
2323 }
2324 typedef struct LDKWatch_JCalls {
2325         atomic_size_t refcnt;
2326         uint32_t watch_channel_meth;
2327         uint32_t update_channel_meth;
2328         uint32_t release_pending_monitor_events_meth;
2329 } LDKWatch_JCalls;
2330 static void LDKWatch_JCalls_free(void* this_arg) {
2331         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2332         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2333                 js_free(j_calls->watch_channel_meth);
2334                 js_free(j_calls->update_channel_meth);
2335                 js_free(j_calls->release_pending_monitor_events_meth);
2336                 FREE(j_calls);
2337         }
2338 }
2339 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
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         LDKChannelMonitor monitor_var = monitor;
2349         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2350         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2351         long monitor_ref = (long)monitor_var.inner;
2352         if (monitor_var.is_owned) {
2353                 monitor_ref |= 1;
2354         }
2355         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_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 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2361         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2362         LDKOutPoint funding_txo_var = funding_txo;
2363         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2364         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2365         long funding_txo_ref = (long)funding_txo_var.inner;
2366         if (funding_txo_var.is_owned) {
2367                 funding_txo_ref |= 1;
2368         }
2369         LDKChannelMonitorUpdate update_var = update;
2370         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2371         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2372         long update_ref = (long)update_var.inner;
2373         if (update_var.is_owned) {
2374                 update_ref |= 1;
2375         }
2376         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2377         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2378         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
2379         return ret_conv;
2380 }
2381 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
2382         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2383         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2384         LDKCVec_MonitorEventZ ret_constr;
2385         ret_constr.datalen = *((uint32_t*)ret);
2386         if (ret_constr.datalen > 0)
2387                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2388         else
2389                 ret_constr.data = NULL;
2390         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2391         for (size_t o = 0; o < ret_constr.datalen; o++) {
2392                 uint32_t ret_conv_14 = ret_vals[o];
2393                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2394                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)ret_conv_14);
2395                 ret_constr.data[o] = ret_conv_14_conv;
2396         }
2397         return ret_constr;
2398 }
2399 static void* LDKWatch_JCalls_clone(const void* this_arg) {
2400         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2401         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2402         return (void*) this_arg;
2403 }
2404 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2405         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2406         atomic_init(&calls->refcnt, 1);
2407         //TODO: Assign calls->o from o
2408
2409         LDKWatch ret = {
2410                 .this_arg = (void*) calls,
2411                 .watch_channel = watch_channel_jcall,
2412                 .update_channel = update_channel_jcall,
2413                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
2414                 .free = LDKWatch_JCalls_free,
2415         };
2416         return ret;
2417 }
2418 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2419         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2420         *res_ptr = LDKWatch_init(o);
2421         return (long)res_ptr;
2422 }
2423 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2424         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2425         LDKOutPoint funding_txo_conv;
2426         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2427         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2428         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2429         LDKChannelMonitor monitor_conv;
2430         monitor_conv.inner = (void*)(monitor & (~1));
2431         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2432         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2433         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2434         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2435         return (long)ret_conv;
2436 }
2437
2438 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2439         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2440         LDKOutPoint funding_txo_conv;
2441         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2442         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2443         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2444         LDKChannelMonitorUpdate update_conv;
2445         update_conv.inner = (void*)(update & (~1));
2446         update_conv.is_owned = (update & 1) || (update == 0);
2447         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2448         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2449         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2450         return (long)ret_conv;
2451 }
2452
2453 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2454         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2455         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2456         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2457         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2458         for (size_t o = 0; o < ret_var.datalen; o++) {
2459                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2460                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2461                 long ret_conv_14_ref = (long)ret_conv_14_copy;
2462                 ret_arr_ptr[o] = ret_conv_14_ref;
2463         }
2464         FREE(ret_var.data);
2465         return ret_arr;
2466 }
2467
2468 typedef struct LDKBroadcasterInterface_JCalls {
2469         atomic_size_t refcnt;
2470         uint32_t broadcast_transaction_meth;
2471 } LDKBroadcasterInterface_JCalls;
2472 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2473         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2474         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2475                 js_free(j_calls->broadcast_transaction_meth);
2476                 FREE(j_calls);
2477         }
2478 }
2479 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
2480         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2481         LDKTransaction tx_var = tx;
2482         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2483         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2484         Transaction_free(tx_var);
2485         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2486 }
2487 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
2488         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2489         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2490         return (void*) this_arg;
2491 }
2492 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2493         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2494         atomic_init(&calls->refcnt, 1);
2495         //TODO: Assign calls->o from o
2496
2497         LDKBroadcasterInterface ret = {
2498                 .this_arg = (void*) calls,
2499                 .broadcast_transaction = broadcast_transaction_jcall,
2500                 .free = LDKBroadcasterInterface_JCalls_free,
2501         };
2502         return ret;
2503 }
2504 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2505         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2506         *res_ptr = LDKBroadcasterInterface_init(o);
2507         return (long)res_ptr;
2508 }
2509 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2510         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2511         LDKTransaction tx_ref;
2512         tx_ref.datalen = *((uint32_t*)tx);
2513         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2514         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2515         tx_ref.data_is_owned = true;
2516         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2517 }
2518
2519 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
2520         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2521 }
2522 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2523         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2524         CHECK(val->result_ok);
2525         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2526         *ret = Sign_clone(&(*val->contents.result));
2527         return (long)ret;
2528 }
2529 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2530         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2531         CHECK(!val->result_ok);
2532         LDKDecodeError err_var = (*val->contents.err);
2533         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2534         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2535         long err_ref = (long)err_var.inner & ~1;
2536         return err_ref;
2537 }
2538 typedef struct LDKKeysInterface_JCalls {
2539         atomic_size_t refcnt;
2540         uint32_t get_node_secret_meth;
2541         uint32_t get_destination_script_meth;
2542         uint32_t get_shutdown_pubkey_meth;
2543         uint32_t get_channel_signer_meth;
2544         uint32_t get_secure_random_bytes_meth;
2545         uint32_t read_chan_signer_meth;
2546 } LDKKeysInterface_JCalls;
2547 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2548         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2549         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2550                 js_free(j_calls->get_node_secret_meth);
2551                 js_free(j_calls->get_destination_script_meth);
2552                 js_free(j_calls->get_shutdown_pubkey_meth);
2553                 js_free(j_calls->get_channel_signer_meth);
2554                 js_free(j_calls->get_secure_random_bytes_meth);
2555                 js_free(j_calls->read_chan_signer_meth);
2556                 FREE(j_calls);
2557         }
2558 }
2559 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
2560         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2561         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2562         LDKSecretKey ret_ref;
2563         CHECK(*((uint32_t*)ret) == 32);
2564         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2565         return ret_ref;
2566 }
2567 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
2568         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2569         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2570         LDKCVec_u8Z ret_ref;
2571         ret_ref.datalen = *((uint32_t*)ret);
2572         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2573         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2574         return ret_ref;
2575 }
2576 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
2577         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2578         int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
2579         LDKPublicKey ret_ref;
2580         CHECK(*((uint32_t*)ret) == 33);
2581         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
2582         return ret_ref;
2583 }
2584 LDKSign get_channel_signer_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2585         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2586         LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2587         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2588         ret_conv = Sign_clone(ret);
2589         return ret_conv;
2590 }
2591 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
2592         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2593         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2594         LDKThirtyTwoBytes ret_ref;
2595         CHECK(*((uint32_t*)ret) == 32);
2596         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2597         return ret_ref;
2598 }
2599 LDKCResult_SignDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
2600         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2601         LDKu8slice reader_var = reader;
2602         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2603         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2604         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2605         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2606         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)ret);
2607         return ret_conv;
2608 }
2609 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
2610         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2611         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2612         return (void*) this_arg;
2613 }
2614 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2615         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2616         atomic_init(&calls->refcnt, 1);
2617         //TODO: Assign calls->o from o
2618
2619         LDKKeysInterface ret = {
2620                 .this_arg = (void*) calls,
2621                 .get_node_secret = get_node_secret_jcall,
2622                 .get_destination_script = get_destination_script_jcall,
2623                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2624                 .get_channel_signer = get_channel_signer_jcall,
2625                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2626                 .read_chan_signer = read_chan_signer_jcall,
2627                 .free = LDKKeysInterface_JCalls_free,
2628         };
2629         return ret;
2630 }
2631 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2632         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2633         *res_ptr = LDKKeysInterface_init(o);
2634         return (long)res_ptr;
2635 }
2636 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2637         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2638         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2639         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2640         return ret_arr;
2641 }
2642
2643 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2644         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2645         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2646         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2647         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2648         CVec_u8Z_free(ret_var);
2649         return ret_arr;
2650 }
2651
2652 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2653         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2654         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2655         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2656         return ret_arr;
2657 }
2658
2659 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2660         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2661         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2662         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2663         return (long)ret;
2664 }
2665
2666 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2667         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2668         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2669         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2670         return ret_arr;
2671 }
2672
2673 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2674         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2675         LDKu8slice reader_ref;
2676         reader_ref.datalen = *((uint32_t*)reader);
2677         reader_ref.data = (int8_t*)(reader + 4);
2678         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2679         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2680         return (long)ret_conv;
2681 }
2682
2683 typedef struct LDKFeeEstimator_JCalls {
2684         atomic_size_t refcnt;
2685         uint32_t get_est_sat_per_1000_weight_meth;
2686 } LDKFeeEstimator_JCalls;
2687 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2688         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2689         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2690                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2691                 FREE(j_calls);
2692         }
2693 }
2694 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2695         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2696         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2697         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2698 }
2699 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2700         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2701         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2702         return (void*) this_arg;
2703 }
2704 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2705         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2706         atomic_init(&calls->refcnt, 1);
2707         //TODO: Assign calls->o from o
2708
2709         LDKFeeEstimator ret = {
2710                 .this_arg = (void*) calls,
2711                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2712                 .free = LDKFeeEstimator_JCalls_free,
2713         };
2714         return ret;
2715 }
2716 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2717         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2718         *res_ptr = LDKFeeEstimator_init(o);
2719         return (long)res_ptr;
2720 }
2721 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2722         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2723         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2724         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2725         return ret_val;
2726 }
2727
2728 typedef struct LDKLogger_JCalls {
2729         atomic_size_t refcnt;
2730         uint32_t log_meth;
2731 } LDKLogger_JCalls;
2732 static void LDKLogger_JCalls_free(void* this_arg) {
2733         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2734         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2735                 js_free(j_calls->log_meth);
2736                 FREE(j_calls);
2737         }
2738 }
2739 void log_jcall(const void* this_arg, const char* record) {
2740         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2741         const char* record_str = record;
2742         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2743         js_invoke_function_1(j_calls->log_meth, record_conv);
2744 }
2745 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2746         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2747         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2748         return (void*) this_arg;
2749 }
2750 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2751         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2752         atomic_init(&calls->refcnt, 1);
2753         //TODO: Assign calls->o from o
2754
2755         LDKLogger ret = {
2756                 .this_arg = (void*) calls,
2757                 .log = log_jcall,
2758                 .free = LDKLogger_JCalls_free,
2759         };
2760         return ret;
2761 }
2762 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2763         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2764         *res_ptr = LDKLogger_init(o);
2765         return (long)res_ptr;
2766 }
2767 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2768         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2769         LDKThirtyTwoBytes a_ref;
2770         CHECK(*((uint32_t*)a) == 32);
2771         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2772         ret->a = a_ref;
2773         LDKChannelManager b_conv;
2774         b_conv.inner = (void*)(b & (~1));
2775         b_conv.is_owned = (b & 1) || (b == 0);
2776         // Warning: we need a move here but no clone is available for LDKChannelManager
2777         ret->b = b_conv;
2778         return (long)ret;
2779 }
2780 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2781         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2782         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2783         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2784         return a_arr;
2785 }
2786 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2787         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
2788         LDKChannelManager b_var = tuple->b;
2789         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         long b_ref = (long)b_var.inner & ~1;
2792         return b_ref;
2793 }
2794 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2795         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2796 }
2797 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2798         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2799         CHECK(val->result_ok);
2800         long res_ref = (long)(&(*val->contents.result)) | 1;
2801         return res_ref;
2802 }
2803 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2804         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
2805         CHECK(!val->result_ok);
2806         LDKDecodeError err_var = (*val->contents.err);
2807         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809         long err_ref = (long)err_var.inner & ~1;
2810         return err_ref;
2811 }
2812 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
2813         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2814 }
2815 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
2816         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2817         CHECK(val->result_ok);
2818         long res_ref = ((long)&(*val->contents.result)) | 1;
2819         return res_ref;
2820 }
2821 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
2822         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2823         CHECK(!val->result_ok);
2824         LDKDecodeError err_var = (*val->contents.err);
2825         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2826         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2827         long err_ref = (long)err_var.inner & ~1;
2828         return err_ref;
2829 }
2830 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2831         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2832         for (size_t i = 0; i < ret.datalen; i++) {
2833                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2834         }
2835         return ret;
2836 }
2837 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2838         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2839 }
2840 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2841         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2842         CHECK(val->result_ok);
2843         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2844         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2845         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2846         for (size_t m = 0; m < res_var.datalen; m++) {
2847                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2848                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2849                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2850                 res_arr_ptr[m] = res_conv_12_arr;
2851         }
2852         return res_arr;
2853 }
2854 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2855         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2856         CHECK(!val->result_ok);
2857         return *val->contents.err;
2858 }
2859 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2860         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2861 }
2862 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2863         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2864         CHECK(val->result_ok);
2865         LDKInMemorySigner res_var = (*val->contents.result);
2866         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868         long res_ref = (long)res_var.inner & ~1;
2869         return res_ref;
2870 }
2871 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2872         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2873         CHECK(!val->result_ok);
2874         LDKDecodeError err_var = (*val->contents.err);
2875         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2876         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2877         long err_ref = (long)err_var.inner & ~1;
2878         return err_ref;
2879 }
2880 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2881         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2882         ret->datalen = *((uint32_t*)elems);
2883         if (ret->datalen == 0) {
2884                 ret->data = NULL;
2885         } else {
2886                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2887                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2888                 for (size_t i = 0; i < ret->datalen; i++) {
2889                         uint32_t arr_elem = java_elems[i];
2890                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2891                         FREE((void*)arr_elem);
2892                         ret->data[i] = arr_elem_conv;
2893                 }
2894         }
2895         return (long)ret;
2896 }
2897 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2898         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2899         for (size_t i = 0; i < ret.datalen; i++) {
2900                 ret.data[i] = TxOut_clone(&orig->data[i]);
2901         }
2902         return ret;
2903 }
2904 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2905         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2906 }
2907 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2908         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2909         CHECK(val->result_ok);
2910         LDKTransaction res_var = (*val->contents.result);
2911         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2912         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2913         return res_arr;
2914 }
2915 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2916         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2917         CHECK(!val->result_ok);
2918         return *val->contents.err;
2919 }
2920 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
2921         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2922         ret->datalen = *((uint32_t*)elems);
2923         if (ret->datalen == 0) {
2924                 ret->data = NULL;
2925         } else {
2926                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2927                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2928                 for (size_t i = 0; i < ret->datalen; i++) {
2929                         uint32_t arr_elem = java_elems[i];
2930                         LDKRouteHop arr_elem_conv;
2931                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2932                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2933                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2934                         ret->data[i] = arr_elem_conv;
2935                 }
2936         }
2937         return (long)ret;
2938 }
2939 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2940         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2941         for (size_t i = 0; i < ret.datalen; i++) {
2942                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2943         }
2944         return ret;
2945 }
2946 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2947         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2948         for (size_t i = 0; i < ret.datalen; i++) {
2949                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2950         }
2951         return ret;
2952 }
2953 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
2954         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2955 }
2956 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
2957         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2958         CHECK(val->result_ok);
2959         LDKRoute res_var = (*val->contents.result);
2960         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2961         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2962         long res_ref = (long)res_var.inner & ~1;
2963         return res_ref;
2964 }
2965 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
2966         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2967         CHECK(!val->result_ok);
2968         LDKDecodeError err_var = (*val->contents.err);
2969         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2970         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2971         long err_ref = (long)err_var.inner & ~1;
2972         return err_ref;
2973 }
2974 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
2975         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2976         ret->datalen = *((uint32_t*)elems);
2977         if (ret->datalen == 0) {
2978                 ret->data = NULL;
2979         } else {
2980                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2981                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2982                 for (size_t i = 0; i < ret->datalen; i++) {
2983                         uint32_t arr_elem = java_elems[i];
2984                         LDKRouteHint arr_elem_conv;
2985                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2986                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2987                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2988                         ret->data[i] = arr_elem_conv;
2989                 }
2990         }
2991         return (long)ret;
2992 }
2993 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2994         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2995         for (size_t i = 0; i < ret.datalen; i++) {
2996                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2997         }
2998         return ret;
2999 }
3000 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
3001         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
3002 }
3003 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
3004         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3005         CHECK(val->result_ok);
3006         LDKRoute res_var = (*val->contents.result);
3007         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3008         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3009         long res_ref = (long)res_var.inner & ~1;
3010         return res_ref;
3011 }
3012 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
3013         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
3014         CHECK(!val->result_ok);
3015         LDKLightningError err_var = (*val->contents.err);
3016         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3017         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3018         long err_ref = (long)err_var.inner & ~1;
3019         return err_ref;
3020 }
3021 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
3022         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
3023 }
3024 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
3025         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3026         CHECK(val->result_ok);
3027         long res_ref = ((long)&(*val->contents.result)) | 1;
3028         return res_ref;
3029 }
3030 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
3031         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
3032         CHECK(!val->result_ok);
3033         return *val->contents.err;
3034 }
3035 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
3036         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
3037 }
3038 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
3039         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3040         CHECK(val->result_ok);
3041         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3042         *res_conv = (*val->contents.result);
3043         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
3044         return (long)res_conv;
3045 }
3046 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
3047         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
3048         CHECK(!val->result_ok);
3049         LDKDecodeError err_var = (*val->contents.err);
3050         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052         long err_ref = (long)err_var.inner & ~1;
3053         return err_ref;
3054 }
3055 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
3056         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
3057         ret->datalen = *((uint32_t*)elems);
3058         if (ret->datalen == 0) {
3059                 ret->data = NULL;
3060         } else {
3061                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
3062                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3063                 for (size_t i = 0; i < ret->datalen; i++) {
3064                         uint32_t arr_elem = java_elems[i];
3065                         LDKUpdateAddHTLC arr_elem_conv;
3066                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3067                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3068                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
3069                         ret->data[i] = arr_elem_conv;
3070                 }
3071         }
3072         return (long)ret;
3073 }
3074 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
3075         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
3076         for (size_t i = 0; i < ret.datalen; i++) {
3077                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
3078         }
3079         return ret;
3080 }
3081 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
3082         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
3083         ret->datalen = *((uint32_t*)elems);
3084         if (ret->datalen == 0) {
3085                 ret->data = NULL;
3086         } else {
3087                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
3088                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3089                 for (size_t i = 0; i < ret->datalen; i++) {
3090                         uint32_t arr_elem = java_elems[i];
3091                         LDKUpdateFulfillHTLC arr_elem_conv;
3092                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3093                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3094                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
3095                         ret->data[i] = arr_elem_conv;
3096                 }
3097         }
3098         return (long)ret;
3099 }
3100 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
3101         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
3102         for (size_t i = 0; i < ret.datalen; i++) {
3103                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
3104         }
3105         return ret;
3106 }
3107 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
3108         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
3109         ret->datalen = *((uint32_t*)elems);
3110         if (ret->datalen == 0) {
3111                 ret->data = NULL;
3112         } else {
3113                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
3114                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3115                 for (size_t i = 0; i < ret->datalen; i++) {
3116                         uint32_t arr_elem = java_elems[i];
3117                         LDKUpdateFailHTLC arr_elem_conv;
3118                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3119                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3120                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
3121                         ret->data[i] = arr_elem_conv;
3122                 }
3123         }
3124         return (long)ret;
3125 }
3126 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
3127         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
3128         for (size_t i = 0; i < ret.datalen; i++) {
3129                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
3130         }
3131         return ret;
3132 }
3133 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
3134         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
3135         ret->datalen = *((uint32_t*)elems);
3136         if (ret->datalen == 0) {
3137                 ret->data = NULL;
3138         } else {
3139                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
3140                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3141                 for (size_t i = 0; i < ret->datalen; i++) {
3142                         uint32_t arr_elem = java_elems[i];
3143                         LDKUpdateFailMalformedHTLC arr_elem_conv;
3144                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3145                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3146                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
3147                         ret->data[i] = arr_elem_conv;
3148                 }
3149         }
3150         return (long)ret;
3151 }
3152 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
3153         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
3154         for (size_t i = 0; i < ret.datalen; i++) {
3155                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
3156         }
3157         return ret;
3158 }
3159 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
3160         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
3161 }
3162 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
3163         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
3164         CHECK(val->result_ok);
3165         LDKAcceptChannel 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_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
3172         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(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_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
3181         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
3182 }
3183 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
3184         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
3185         CHECK(val->result_ok);
3186         LDKAnnouncementSignatures 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_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
3193         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(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_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
3202         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
3203 }
3204 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
3205         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
3206         CHECK(val->result_ok);
3207         LDKChannelReestablish 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_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
3214         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(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_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3223         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
3224 }
3225 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3226         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
3227         CHECK(val->result_ok);
3228         LDKClosingSigned 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_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
3235         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(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_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
3244         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
3245 }
3246 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
3247         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
3248         CHECK(val->result_ok);
3249         LDKCommitmentSigned 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_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
3256         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(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_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
3265         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
3266 }
3267 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
3268         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
3269         CHECK(val->result_ok);
3270         LDKFundingCreated 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_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
3277         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(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_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
3286         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
3287 }
3288 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
3289         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
3290         CHECK(val->result_ok);
3291         LDKFundingSigned 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_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
3298         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(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_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
3307         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
3308 }
3309 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
3310         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
3311         CHECK(val->result_ok);
3312         LDKFundingLocked 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_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
3319         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(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_InitDecodeErrorZ_result_ok(uint32_t arg) {
3328         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
3329 }
3330 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
3331         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
3332         CHECK(val->result_ok);
3333         LDKInit 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_InitDecodeErrorZ_get_err(uint32_t arg) {
3340         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(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_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
3349         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
3350 }
3351 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
3352         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
3353         CHECK(val->result_ok);
3354         LDKOpenChannel 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_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
3361         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(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_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
3370         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
3371 }
3372 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
3373         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
3374         CHECK(val->result_ok);
3375         LDKRevokeAndACK 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_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
3382         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(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_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
3391         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
3392 }
3393 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
3394         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
3395         CHECK(val->result_ok);
3396         LDKShutdown 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_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
3403         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(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_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3412         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
3413 }
3414 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3415         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
3416         CHECK(val->result_ok);
3417         LDKUpdateFailHTLC 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_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
3424         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(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_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3433         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
3434 }
3435 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3436         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
3437         CHECK(val->result_ok);
3438         LDKUpdateFailMalformedHTLC 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_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
3445         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(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_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
3454         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
3455 }
3456 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
3457         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
3458         CHECK(val->result_ok);
3459         LDKUpdateFee 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_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
3466         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(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_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3475         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
3476 }
3477 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3478         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
3479         CHECK(val->result_ok);
3480         LDKUpdateFulfillHTLC 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_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
3487         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(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_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
3496         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
3497 }
3498 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
3499         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
3500         CHECK(val->result_ok);
3501         LDKUpdateAddHTLC 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_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
3508         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(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_PingDecodeErrorZ_result_ok(uint32_t arg) {
3517         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
3518 }
3519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
3520         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
3521         CHECK(val->result_ok);
3522         LDKPing 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_PingDecodeErrorZ_get_err(uint32_t arg) {
3529         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(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_PongDecodeErrorZ_result_ok(uint32_t arg) {
3538         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
3539 }
3540 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
3541         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
3542         CHECK(val->result_ok);
3543         LDKPong 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_PongDecodeErrorZ_get_err(uint32_t arg) {
3550         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(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_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3559         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3560 }
3561 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3562         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3563         CHECK(val->result_ok);
3564         LDKUnsignedChannelAnnouncement 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_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3571         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(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_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3580         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
3581 }
3582 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3583         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
3584         CHECK(val->result_ok);
3585         LDKChannelAnnouncement 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_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3592         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(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_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3601         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
3602 }
3603 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3604         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
3605         CHECK(val->result_ok);
3606         LDKUnsignedChannelUpdate 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_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3613         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(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_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3622         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
3623 }
3624 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3625         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
3626         CHECK(val->result_ok);
3627         LDKChannelUpdate 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_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
3634         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(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_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
3643         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
3644 }
3645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
3646         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
3647         CHECK(val->result_ok);
3648         LDKErrorMessage 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_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
3655         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(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_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3664         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3665 }
3666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3667         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
3668         CHECK(val->result_ok);
3669         LDKUnsignedNodeAnnouncement 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_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3676         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(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_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
3685         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
3686 }
3687 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
3688         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
3689         CHECK(val->result_ok);
3690         LDKNodeAnnouncement 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_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
3697         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(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_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
3706         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
3707 }
3708 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
3709         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
3710         CHECK(val->result_ok);
3711         LDKQueryShortChannelIds 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_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
3718         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(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_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
3727         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
3728 }
3729 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
3730         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
3731         CHECK(val->result_ok);
3732         LDKReplyShortChannelIdsEnd 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_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
3739         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(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_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3748         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
3749 }
3750 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3751         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
3752         CHECK(val->result_ok);
3753         LDKQueryChannelRange 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_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3760         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(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_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
3769         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
3770 }
3771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
3772         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
3773         CHECK(val->result_ok);
3774         LDKReplyChannelRange 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_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
3781         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(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 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
3790         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
3791 }
3792 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
3793         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3794         CHECK(val->result_ok);
3795         LDKGossipTimestampFilter res_var = (*val->contents.result);
3796         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3797         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3798         long res_ref = (long)res_var.inner & ~1;
3799         return res_ref;
3800 }
3801 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
3802         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
3803         CHECK(!val->result_ok);
3804         LDKDecodeError err_var = (*val->contents.err);
3805         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3806         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3807         long err_ref = (long)err_var.inner & ~1;
3808         return err_ref;
3809 }
3810 typedef struct LDKMessageSendEventsProvider_JCalls {
3811         atomic_size_t refcnt;
3812         uint32_t get_and_clear_pending_msg_events_meth;
3813 } LDKMessageSendEventsProvider_JCalls;
3814 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
3815         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3816         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3817                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
3818                 FREE(j_calls);
3819         }
3820 }
3821 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
3822         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3823         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
3824         LDKCVec_MessageSendEventZ ret_constr;
3825         ret_constr.datalen = *((uint32_t*)ret);
3826         if (ret_constr.datalen > 0)
3827                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3828         else
3829                 ret_constr.data = NULL;
3830         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3831         for (size_t s = 0; s < ret_constr.datalen; s++) {
3832                 uint32_t ret_conv_18 = ret_vals[s];
3833                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
3834                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)ret_conv_18);
3835                 ret_constr.data[s] = ret_conv_18_conv;
3836         }
3837         return ret_constr;
3838 }
3839 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
3840         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3841         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3842         return (void*) this_arg;
3843 }
3844 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3845         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
3846         atomic_init(&calls->refcnt, 1);
3847         //TODO: Assign calls->o from o
3848
3849         LDKMessageSendEventsProvider ret = {
3850                 .this_arg = (void*) calls,
3851                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
3852                 .free = LDKMessageSendEventsProvider_JCalls_free,
3853         };
3854         return ret;
3855 }
3856 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3857         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
3858         *res_ptr = LDKMessageSendEventsProvider_init(o);
3859         return (long)res_ptr;
3860 }
3861 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
3862         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
3863         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
3864         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3865         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3866         for (size_t s = 0; s < ret_var.datalen; s++) {
3867                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
3868                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
3869                 long ret_conv_18_ref = (long)ret_conv_18_copy;
3870                 ret_arr_ptr[s] = ret_conv_18_ref;
3871         }
3872         FREE(ret_var.data);
3873         return ret_arr;
3874 }
3875
3876 typedef struct LDKEventsProvider_JCalls {
3877         atomic_size_t refcnt;
3878         uint32_t get_and_clear_pending_events_meth;
3879 } LDKEventsProvider_JCalls;
3880 static void LDKEventsProvider_JCalls_free(void* this_arg) {
3881         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3882         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3883                 js_free(j_calls->get_and_clear_pending_events_meth);
3884                 FREE(j_calls);
3885         }
3886 }
3887 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
3888         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3889         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
3890         LDKCVec_EventZ ret_constr;
3891         ret_constr.datalen = *((uint32_t*)ret);
3892         if (ret_constr.datalen > 0)
3893                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3894         else
3895                 ret_constr.data = NULL;
3896         uint32_t* ret_vals = (uint32_t*)(ret + 4);
3897         for (size_t h = 0; h < ret_constr.datalen; h++) {
3898                 uint32_t ret_conv_7 = ret_vals[h];
3899                 LDKEvent ret_conv_7_conv = *(LDKEvent*)(((uint64_t)ret_conv_7) & ~1);
3900                 ret_conv_7_conv = Event_clone((LDKEvent*)ret_conv_7);
3901                 ret_constr.data[h] = ret_conv_7_conv;
3902         }
3903         return ret_constr;
3904 }
3905 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
3906         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3907         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3908         return (void*) this_arg;
3909 }
3910 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3911         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
3912         atomic_init(&calls->refcnt, 1);
3913         //TODO: Assign calls->o from o
3914
3915         LDKEventsProvider ret = {
3916                 .this_arg = (void*) calls,
3917                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
3918                 .free = LDKEventsProvider_JCalls_free,
3919         };
3920         return ret;
3921 }
3922 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3923         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
3924         *res_ptr = LDKEventsProvider_init(o);
3925         return (long)res_ptr;
3926 }
3927 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
3928         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
3929         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
3930         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3931         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3932         for (size_t h = 0; h < ret_var.datalen; h++) {
3933                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
3934                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
3935                 long ret_conv_7_ref = (long)ret_conv_7_copy;
3936                 ret_arr_ptr[h] = ret_conv_7_ref;
3937         }
3938         FREE(ret_var.data);
3939         return ret_arr;
3940 }
3941
3942 typedef struct LDKAccess_JCalls {
3943         atomic_size_t refcnt;
3944         uint32_t get_utxo_meth;
3945 } LDKAccess_JCalls;
3946 static void LDKAccess_JCalls_free(void* this_arg) {
3947         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3948         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3949                 js_free(j_calls->get_utxo_meth);
3950                 FREE(j_calls);
3951         }
3952 }
3953 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3954         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3955         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3956         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
3957         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
3958         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
3959         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
3960         return ret_conv;
3961 }
3962 static void* LDKAccess_JCalls_clone(const void* this_arg) {
3963         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3964         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3965         return (void*) this_arg;
3966 }
3967 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
3968         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3969         atomic_init(&calls->refcnt, 1);
3970         //TODO: Assign calls->o from o
3971
3972         LDKAccess ret = {
3973                 .this_arg = (void*) calls,
3974                 .get_utxo = get_utxo_jcall,
3975                 .free = LDKAccess_JCalls_free,
3976         };
3977         return ret;
3978 }
3979 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
3980         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3981         *res_ptr = LDKAccess_init(o);
3982         return (long)res_ptr;
3983 }
3984 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3985         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
3986         unsigned char genesis_hash_arr[32];
3987         CHECK(*((uint32_t*)genesis_hash) == 32);
3988         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
3989         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3990         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3991         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3992         return (long)ret_conv;
3993 }
3994
3995 typedef struct LDKListen_JCalls {
3996         atomic_size_t refcnt;
3997         uint32_t block_connected_meth;
3998         uint32_t block_disconnected_meth;
3999 } LDKListen_JCalls;
4000 static void LDKListen_JCalls_free(void* this_arg) {
4001         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4002         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4003                 js_free(j_calls->block_connected_meth);
4004                 js_free(j_calls->block_disconnected_meth);
4005                 FREE(j_calls);
4006         }
4007 }
4008 void block_connected_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
4009         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4010         LDKu8slice block_var = block;
4011         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4012         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
4013         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
4014 }
4015 void block_disconnected_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
4016         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4017         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
4018         memcpy((uint8_t*)(header_arr + 4), *header, 80);
4019         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
4020 }
4021 static void* LDKListen_JCalls_clone(const void* this_arg) {
4022         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
4023         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4024         return (void*) this_arg;
4025 }
4026 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
4027         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
4028         atomic_init(&calls->refcnt, 1);
4029         //TODO: Assign calls->o from o
4030
4031         LDKListen ret = {
4032                 .this_arg = (void*) calls,
4033                 .block_connected = block_connected_jcall,
4034                 .block_disconnected = block_disconnected_jcall,
4035                 .free = LDKListen_JCalls_free,
4036         };
4037         return ret;
4038 }
4039 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
4040         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
4041         *res_ptr = LDKListen_init(o);
4042         return (long)res_ptr;
4043 }
4044 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
4045         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4046         LDKu8slice block_ref;
4047         block_ref.datalen = *((uint32_t*)block);
4048         block_ref.data = (int8_t*)(block + 4);
4049         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
4050 }
4051
4052 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
4053         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
4054         unsigned char header_arr[80];
4055         CHECK(*((uint32_t*)header) == 80);
4056         memcpy(header_arr, (uint8_t*)(header + 4), 80);
4057         unsigned char (*header_ref)[80] = &header_arr;
4058         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
4059 }
4060
4061 typedef struct LDKFilter_JCalls {
4062         atomic_size_t refcnt;
4063         uint32_t register_tx_meth;
4064         uint32_t register_output_meth;
4065 } LDKFilter_JCalls;
4066 static void LDKFilter_JCalls_free(void* this_arg) {
4067         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4068         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4069                 js_free(j_calls->register_tx_meth);
4070                 js_free(j_calls->register_output_meth);
4071                 FREE(j_calls);
4072         }
4073 }
4074 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
4075         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4076         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4077         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
4078         LDKu8slice script_pubkey_var = script_pubkey;
4079         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4080         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4081         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
4082 }
4083 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
4084         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4085         LDKOutPoint outpoint_var = *outpoint;
4086         outpoint_var = OutPoint_clone(outpoint);
4087         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4088         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4089         long outpoint_ref = (long)outpoint_var.inner;
4090         if (outpoint_var.is_owned) {
4091                 outpoint_ref |= 1;
4092         }
4093         LDKu8slice script_pubkey_var = script_pubkey;
4094         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4095         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
4096         js_invoke_function_2(j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
4097 }
4098 static void* LDKFilter_JCalls_clone(const void* this_arg) {
4099         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
4100         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4101         return (void*) this_arg;
4102 }
4103 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
4104         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
4105         atomic_init(&calls->refcnt, 1);
4106         //TODO: Assign calls->o from o
4107
4108         LDKFilter ret = {
4109                 .this_arg = (void*) calls,
4110                 .register_tx = register_tx_jcall,
4111                 .register_output = register_output_jcall,
4112                 .free = LDKFilter_JCalls_free,
4113         };
4114         return ret;
4115 }
4116 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
4117         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
4118         *res_ptr = LDKFilter_init(o);
4119         return (long)res_ptr;
4120 }
4121 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
4122         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4123         unsigned char txid_arr[32];
4124         CHECK(*((uint32_t*)txid) == 32);
4125         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
4126         unsigned char (*txid_ref)[32] = &txid_arr;
4127         LDKu8slice script_pubkey_ref;
4128         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4129         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4130         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
4131 }
4132
4133 void  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
4134         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
4135         LDKOutPoint outpoint_conv;
4136         outpoint_conv.inner = (void*)(outpoint & (~1));
4137         outpoint_conv.is_owned = false;
4138         LDKu8slice script_pubkey_ref;
4139         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
4140         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
4141         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
4142 }
4143
4144 typedef struct LDKPersist_JCalls {
4145         atomic_size_t refcnt;
4146         uint32_t persist_new_channel_meth;
4147         uint32_t update_persisted_channel_meth;
4148 } LDKPersist_JCalls;
4149 static void LDKPersist_JCalls_free(void* this_arg) {
4150         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4151         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4152                 js_free(j_calls->persist_new_channel_meth);
4153                 js_free(j_calls->update_persisted_channel_meth);
4154                 FREE(j_calls);
4155         }
4156 }
4157 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
4158         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4159         LDKOutPoint id_var = id;
4160         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4161         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4162         long id_ref = (long)id_var.inner;
4163         if (id_var.is_owned) {
4164                 id_ref |= 1;
4165         }
4166         LDKChannelMonitor data_var = *data;
4167         data_var = ChannelMonitor_clone(data);
4168         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4169         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4170         long data_ref = (long)data_var.inner;
4171         if (data_var.is_owned) {
4172                 data_ref |= 1;
4173         }
4174         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
4175         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4176         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4177         return ret_conv;
4178 }
4179 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
4180         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4181         LDKOutPoint id_var = id;
4182         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         long id_ref = (long)id_var.inner;
4185         if (id_var.is_owned) {
4186                 id_ref |= 1;
4187         }
4188         LDKChannelMonitorUpdate update_var = *update;
4189         update_var = ChannelMonitorUpdate_clone(update);
4190         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4191         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4192         long update_ref = (long)update_var.inner;
4193         if (update_var.is_owned) {
4194                 update_ref |= 1;
4195         }
4196         LDKChannelMonitor data_var = *data;
4197         data_var = ChannelMonitor_clone(data);
4198         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4199         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4200         long data_ref = (long)data_var.inner;
4201         if (data_var.is_owned) {
4202                 data_ref |= 1;
4203         }
4204         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
4205         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
4206         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
4207         return ret_conv;
4208 }
4209 static void* LDKPersist_JCalls_clone(const void* this_arg) {
4210         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
4211         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4212         return (void*) this_arg;
4213 }
4214 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
4215         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
4216         atomic_init(&calls->refcnt, 1);
4217         //TODO: Assign calls->o from o
4218
4219         LDKPersist ret = {
4220                 .this_arg = (void*) calls,
4221                 .persist_new_channel = persist_new_channel_jcall,
4222                 .update_persisted_channel = update_persisted_channel_jcall,
4223                 .free = LDKPersist_JCalls_free,
4224         };
4225         return ret;
4226 }
4227 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
4228         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
4229         *res_ptr = LDKPersist_init(o);
4230         return (long)res_ptr;
4231 }
4232 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
4233         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4234         LDKOutPoint id_conv;
4235         id_conv.inner = (void*)(id & (~1));
4236         id_conv.is_owned = (id & 1) || (id == 0);
4237         id_conv = OutPoint_clone(&id_conv);
4238         LDKChannelMonitor data_conv;
4239         data_conv.inner = (void*)(data & (~1));
4240         data_conv.is_owned = false;
4241         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4242         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
4243         return (long)ret_conv;
4244 }
4245
4246 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
4247         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
4248         LDKOutPoint id_conv;
4249         id_conv.inner = (void*)(id & (~1));
4250         id_conv.is_owned = (id & 1) || (id == 0);
4251         id_conv = OutPoint_clone(&id_conv);
4252         LDKChannelMonitorUpdate update_conv;
4253         update_conv.inner = (void*)(update & (~1));
4254         update_conv.is_owned = false;
4255         LDKChannelMonitor data_conv;
4256         data_conv.inner = (void*)(data & (~1));
4257         data_conv.is_owned = false;
4258         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4259         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
4260         return (long)ret_conv;
4261 }
4262
4263 typedef struct LDKChannelMessageHandler_JCalls {
4264         atomic_size_t refcnt;
4265         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4266         uint32_t handle_open_channel_meth;
4267         uint32_t handle_accept_channel_meth;
4268         uint32_t handle_funding_created_meth;
4269         uint32_t handle_funding_signed_meth;
4270         uint32_t handle_funding_locked_meth;
4271         uint32_t handle_shutdown_meth;
4272         uint32_t handle_closing_signed_meth;
4273         uint32_t handle_update_add_htlc_meth;
4274         uint32_t handle_update_fulfill_htlc_meth;
4275         uint32_t handle_update_fail_htlc_meth;
4276         uint32_t handle_update_fail_malformed_htlc_meth;
4277         uint32_t handle_commitment_signed_meth;
4278         uint32_t handle_revoke_and_ack_meth;
4279         uint32_t handle_update_fee_meth;
4280         uint32_t handle_announcement_signatures_meth;
4281         uint32_t peer_disconnected_meth;
4282         uint32_t peer_connected_meth;
4283         uint32_t handle_channel_reestablish_meth;
4284         uint32_t handle_error_meth;
4285 } LDKChannelMessageHandler_JCalls;
4286 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
4287         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4288         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4289                 js_free(j_calls->handle_open_channel_meth);
4290                 js_free(j_calls->handle_accept_channel_meth);
4291                 js_free(j_calls->handle_funding_created_meth);
4292                 js_free(j_calls->handle_funding_signed_meth);
4293                 js_free(j_calls->handle_funding_locked_meth);
4294                 js_free(j_calls->handle_shutdown_meth);
4295                 js_free(j_calls->handle_closing_signed_meth);
4296                 js_free(j_calls->handle_update_add_htlc_meth);
4297                 js_free(j_calls->handle_update_fulfill_htlc_meth);
4298                 js_free(j_calls->handle_update_fail_htlc_meth);
4299                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
4300                 js_free(j_calls->handle_commitment_signed_meth);
4301                 js_free(j_calls->handle_revoke_and_ack_meth);
4302                 js_free(j_calls->handle_update_fee_meth);
4303                 js_free(j_calls->handle_announcement_signatures_meth);
4304                 js_free(j_calls->peer_disconnected_meth);
4305                 js_free(j_calls->peer_connected_meth);
4306                 js_free(j_calls->handle_channel_reestablish_meth);
4307                 js_free(j_calls->handle_error_meth);
4308                 FREE(j_calls);
4309         }
4310 }
4311 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * 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         LDKOpenChannel msg_var = *msg;
4323         msg_var = OpenChannel_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_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4331 }
4332 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * 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         LDKInitFeatures their_features_var = their_features;
4337         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4338         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4339         long their_features_ref = (long)their_features_var.inner;
4340         if (their_features_var.is_owned) {
4341                 their_features_ref |= 1;
4342         }
4343         LDKAcceptChannel msg_var = *msg;
4344         msg_var = AcceptChannel_clone(msg);
4345         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4346         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4347         long msg_ref = (long)msg_var.inner;
4348         if (msg_var.is_owned) {
4349                 msg_ref |= 1;
4350         }
4351         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
4352 }
4353 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
4354         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4355         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4356         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4357         LDKFundingCreated msg_var = *msg;
4358         msg_var = FundingCreated_clone(msg);
4359         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         long msg_ref = (long)msg_var.inner;
4362         if (msg_var.is_owned) {
4363                 msg_ref |= 1;
4364         }
4365         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
4366 }
4367 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
4368         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4369         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4370         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4371         LDKFundingSigned msg_var = *msg;
4372         msg_var = FundingSigned_clone(msg);
4373         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4374         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4375         long msg_ref = (long)msg_var.inner;
4376         if (msg_var.is_owned) {
4377                 msg_ref |= 1;
4378         }
4379         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
4380 }
4381 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
4382         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4383         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4384         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4385         LDKFundingLocked msg_var = *msg;
4386         msg_var = FundingLocked_clone(msg);
4387         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4388         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4389         long msg_ref = (long)msg_var.inner;
4390         if (msg_var.is_owned) {
4391                 msg_ref |= 1;
4392         }
4393         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
4394 }
4395 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
4396         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4397         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4398         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4399         LDKInitFeatures their_features_var = *their_features;
4400         their_features_var = InitFeatures_clone(their_features);
4401         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4402         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4403         long their_features_ref = (long)their_features_var.inner;
4404         if (their_features_var.is_owned) {
4405                 their_features_ref |= 1;
4406         }
4407         LDKShutdown msg_var = *msg;
4408         msg_var = Shutdown_clone(msg);
4409         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4410         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4411         long msg_ref = (long)msg_var.inner;
4412         if (msg_var.is_owned) {
4413                 msg_ref |= 1;
4414         }
4415         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
4416 }
4417 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
4418         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4419         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4420         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4421         LDKClosingSigned msg_var = *msg;
4422         msg_var = ClosingSigned_clone(msg);
4423         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4424         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4425         long msg_ref = (long)msg_var.inner;
4426         if (msg_var.is_owned) {
4427                 msg_ref |= 1;
4428         }
4429         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
4430 }
4431 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
4432         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4433         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4434         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4435         LDKUpdateAddHTLC msg_var = *msg;
4436         msg_var = UpdateAddHTLC_clone(msg);
4437         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4438         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4439         long msg_ref = (long)msg_var.inner;
4440         if (msg_var.is_owned) {
4441                 msg_ref |= 1;
4442         }
4443         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
4444 }
4445 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
4446         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4447         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4448         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4449         LDKUpdateFulfillHTLC msg_var = *msg;
4450         msg_var = UpdateFulfillHTLC_clone(msg);
4451         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4452         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4453         long msg_ref = (long)msg_var.inner;
4454         if (msg_var.is_owned) {
4455                 msg_ref |= 1;
4456         }
4457         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
4458 }
4459 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
4460         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4461         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4462         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4463         LDKUpdateFailHTLC msg_var = *msg;
4464         msg_var = UpdateFailHTLC_clone(msg);
4465         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4466         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4467         long msg_ref = (long)msg_var.inner;
4468         if (msg_var.is_owned) {
4469                 msg_ref |= 1;
4470         }
4471         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
4472 }
4473 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
4474         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4475         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4476         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4477         LDKUpdateFailMalformedHTLC msg_var = *msg;
4478         msg_var = UpdateFailMalformedHTLC_clone(msg);
4479         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4480         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4481         long msg_ref = (long)msg_var.inner;
4482         if (msg_var.is_owned) {
4483                 msg_ref |= 1;
4484         }
4485         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
4486 }
4487 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
4488         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4489         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4490         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4491         LDKCommitmentSigned msg_var = *msg;
4492         msg_var = CommitmentSigned_clone(msg);
4493         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4494         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4495         long msg_ref = (long)msg_var.inner;
4496         if (msg_var.is_owned) {
4497                 msg_ref |= 1;
4498         }
4499         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
4500 }
4501 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
4502         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4503         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4504         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4505         LDKRevokeAndACK msg_var = *msg;
4506         msg_var = RevokeAndACK_clone(msg);
4507         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4508         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4509         long msg_ref = (long)msg_var.inner;
4510         if (msg_var.is_owned) {
4511                 msg_ref |= 1;
4512         }
4513         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
4514 }
4515 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
4516         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4517         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4518         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4519         LDKUpdateFee msg_var = *msg;
4520         msg_var = UpdateFee_clone(msg);
4521         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4522         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4523         long msg_ref = (long)msg_var.inner;
4524         if (msg_var.is_owned) {
4525                 msg_ref |= 1;
4526         }
4527         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
4528 }
4529 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
4530         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4531         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4532         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4533         LDKAnnouncementSignatures msg_var = *msg;
4534         msg_var = AnnouncementSignatures_clone(msg);
4535         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4536         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4537         long msg_ref = (long)msg_var.inner;
4538         if (msg_var.is_owned) {
4539                 msg_ref |= 1;
4540         }
4541         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
4542 }
4543 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
4544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4545         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4546         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4547         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
4548 }
4549 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
4550         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4551         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4552         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4553         LDKInit msg_var = *msg;
4554         msg_var = Init_clone(msg);
4555         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4556         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4557         long msg_ref = (long)msg_var.inner;
4558         if (msg_var.is_owned) {
4559                 msg_ref |= 1;
4560         }
4561         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
4562 }
4563 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
4564         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4565         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4566         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4567         LDKChannelReestablish msg_var = *msg;
4568         msg_var = ChannelReestablish_clone(msg);
4569         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4570         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4571         long msg_ref = (long)msg_var.inner;
4572         if (msg_var.is_owned) {
4573                 msg_ref |= 1;
4574         }
4575         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
4576 }
4577 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
4578         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4579         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4580         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4581         LDKErrorMessage msg_var = *msg;
4582         msg_var = ErrorMessage_clone(msg);
4583         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4584         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4585         long msg_ref = (long)msg_var.inner;
4586         if (msg_var.is_owned) {
4587                 msg_ref |= 1;
4588         }
4589         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
4590 }
4591 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
4592         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
4593         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4594         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4595         return (void*) this_arg;
4596 }
4597 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4598         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
4599         atomic_init(&calls->refcnt, 1);
4600         //TODO: Assign calls->o from o
4601
4602         LDKChannelMessageHandler ret = {
4603                 .this_arg = (void*) calls,
4604                 .handle_open_channel = handle_open_channel_jcall,
4605                 .handle_accept_channel = handle_accept_channel_jcall,
4606                 .handle_funding_created = handle_funding_created_jcall,
4607                 .handle_funding_signed = handle_funding_signed_jcall,
4608                 .handle_funding_locked = handle_funding_locked_jcall,
4609                 .handle_shutdown = handle_shutdown_jcall,
4610                 .handle_closing_signed = handle_closing_signed_jcall,
4611                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
4612                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
4613                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
4614                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
4615                 .handle_commitment_signed = handle_commitment_signed_jcall,
4616                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
4617                 .handle_update_fee = handle_update_fee_jcall,
4618                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
4619                 .peer_disconnected = peer_disconnected_jcall,
4620                 .peer_connected = peer_connected_jcall,
4621                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
4622                 .handle_error = handle_error_jcall,
4623                 .free = LDKChannelMessageHandler_JCalls_free,
4624                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4625         };
4626         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4627         return ret;
4628 }
4629 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4630         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
4631         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
4632         return (long)res_ptr;
4633 }
4634 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) {
4635         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4636         LDKPublicKey their_node_id_ref;
4637         CHECK(*((uint32_t*)their_node_id) == 33);
4638         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4639         LDKInitFeatures their_features_conv;
4640         their_features_conv.inner = (void*)(their_features & (~1));
4641         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4642         their_features_conv = InitFeatures_clone(&their_features_conv);
4643         LDKOpenChannel msg_conv;
4644         msg_conv.inner = (void*)(msg & (~1));
4645         msg_conv.is_owned = false;
4646         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4647 }
4648
4649 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) {
4650         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4651         LDKPublicKey their_node_id_ref;
4652         CHECK(*((uint32_t*)their_node_id) == 33);
4653         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4654         LDKInitFeatures their_features_conv;
4655         their_features_conv.inner = (void*)(their_features & (~1));
4656         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
4657         their_features_conv = InitFeatures_clone(&their_features_conv);
4658         LDKAcceptChannel msg_conv;
4659         msg_conv.inner = (void*)(msg & (~1));
4660         msg_conv.is_owned = false;
4661         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
4662 }
4663
4664 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4665         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4666         LDKPublicKey their_node_id_ref;
4667         CHECK(*((uint32_t*)their_node_id) == 33);
4668         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4669         LDKFundingCreated msg_conv;
4670         msg_conv.inner = (void*)(msg & (~1));
4671         msg_conv.is_owned = false;
4672         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4673 }
4674
4675 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4676         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4677         LDKPublicKey their_node_id_ref;
4678         CHECK(*((uint32_t*)their_node_id) == 33);
4679         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4680         LDKFundingSigned msg_conv;
4681         msg_conv.inner = (void*)(msg & (~1));
4682         msg_conv.is_owned = false;
4683         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4684 }
4685
4686 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4688         LDKPublicKey their_node_id_ref;
4689         CHECK(*((uint32_t*)their_node_id) == 33);
4690         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4691         LDKFundingLocked msg_conv;
4692         msg_conv.inner = (void*)(msg & (~1));
4693         msg_conv.is_owned = false;
4694         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4695 }
4696
4697 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
4698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4699         LDKPublicKey their_node_id_ref;
4700         CHECK(*((uint32_t*)their_node_id) == 33);
4701         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4702         LDKInitFeatures their_features_conv;
4703         their_features_conv.inner = (void*)(their_features & (~1));
4704         their_features_conv.is_owned = false;
4705         LDKShutdown msg_conv;
4706         msg_conv.inner = (void*)(msg & (~1));
4707         msg_conv.is_owned = false;
4708         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
4709 }
4710
4711 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4712         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4713         LDKPublicKey their_node_id_ref;
4714         CHECK(*((uint32_t*)their_node_id) == 33);
4715         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4716         LDKClosingSigned msg_conv;
4717         msg_conv.inner = (void*)(msg & (~1));
4718         msg_conv.is_owned = false;
4719         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4720 }
4721
4722 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4723         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4724         LDKPublicKey their_node_id_ref;
4725         CHECK(*((uint32_t*)their_node_id) == 33);
4726         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4727         LDKUpdateAddHTLC msg_conv;
4728         msg_conv.inner = (void*)(msg & (~1));
4729         msg_conv.is_owned = false;
4730         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4731 }
4732
4733 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4734         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4735         LDKPublicKey their_node_id_ref;
4736         CHECK(*((uint32_t*)their_node_id) == 33);
4737         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4738         LDKUpdateFulfillHTLC msg_conv;
4739         msg_conv.inner = (void*)(msg & (~1));
4740         msg_conv.is_owned = false;
4741         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4742 }
4743
4744 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4746         LDKPublicKey their_node_id_ref;
4747         CHECK(*((uint32_t*)their_node_id) == 33);
4748         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4749         LDKUpdateFailHTLC msg_conv;
4750         msg_conv.inner = (void*)(msg & (~1));
4751         msg_conv.is_owned = false;
4752         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4753 }
4754
4755 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4756         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4757         LDKPublicKey their_node_id_ref;
4758         CHECK(*((uint32_t*)their_node_id) == 33);
4759         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4760         LDKUpdateFailMalformedHTLC msg_conv;
4761         msg_conv.inner = (void*)(msg & (~1));
4762         msg_conv.is_owned = false;
4763         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4764 }
4765
4766 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4767         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4768         LDKPublicKey their_node_id_ref;
4769         CHECK(*((uint32_t*)their_node_id) == 33);
4770         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4771         LDKCommitmentSigned msg_conv;
4772         msg_conv.inner = (void*)(msg & (~1));
4773         msg_conv.is_owned = false;
4774         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4775 }
4776
4777 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4778         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4779         LDKPublicKey their_node_id_ref;
4780         CHECK(*((uint32_t*)their_node_id) == 33);
4781         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4782         LDKRevokeAndACK msg_conv;
4783         msg_conv.inner = (void*)(msg & (~1));
4784         msg_conv.is_owned = false;
4785         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4786 }
4787
4788 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4789         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4790         LDKPublicKey their_node_id_ref;
4791         CHECK(*((uint32_t*)their_node_id) == 33);
4792         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4793         LDKUpdateFee msg_conv;
4794         msg_conv.inner = (void*)(msg & (~1));
4795         msg_conv.is_owned = false;
4796         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4797 }
4798
4799 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4800         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4801         LDKPublicKey their_node_id_ref;
4802         CHECK(*((uint32_t*)their_node_id) == 33);
4803         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4804         LDKAnnouncementSignatures msg_conv;
4805         msg_conv.inner = (void*)(msg & (~1));
4806         msg_conv.is_owned = false;
4807         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4808 }
4809
4810 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
4811         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4812         LDKPublicKey their_node_id_ref;
4813         CHECK(*((uint32_t*)their_node_id) == 33);
4814         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4815         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
4816 }
4817
4818 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4820         LDKPublicKey their_node_id_ref;
4821         CHECK(*((uint32_t*)their_node_id) == 33);
4822         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4823         LDKInit msg_conv;
4824         msg_conv.inner = (void*)(msg & (~1));
4825         msg_conv.is_owned = false;
4826         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4827 }
4828
4829 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4830         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4831         LDKPublicKey their_node_id_ref;
4832         CHECK(*((uint32_t*)their_node_id) == 33);
4833         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4834         LDKChannelReestablish msg_conv;
4835         msg_conv.inner = (void*)(msg & (~1));
4836         msg_conv.is_owned = false;
4837         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4838 }
4839
4840 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4841         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
4842         LDKPublicKey their_node_id_ref;
4843         CHECK(*((uint32_t*)their_node_id) == 33);
4844         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4845         LDKErrorMessage msg_conv;
4846         msg_conv.inner = (void*)(msg & (~1));
4847         msg_conv.is_owned = false;
4848         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4849 }
4850
4851 typedef struct LDKRoutingMessageHandler_JCalls {
4852         atomic_size_t refcnt;
4853         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4854         uint32_t handle_node_announcement_meth;
4855         uint32_t handle_channel_announcement_meth;
4856         uint32_t handle_channel_update_meth;
4857         uint32_t handle_htlc_fail_channel_update_meth;
4858         uint32_t get_next_channel_announcements_meth;
4859         uint32_t get_next_node_announcements_meth;
4860         uint32_t sync_routing_table_meth;
4861         uint32_t handle_reply_channel_range_meth;
4862         uint32_t handle_reply_short_channel_ids_end_meth;
4863         uint32_t handle_query_channel_range_meth;
4864         uint32_t handle_query_short_channel_ids_meth;
4865 } LDKRoutingMessageHandler_JCalls;
4866 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
4867         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4868         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4869                 js_free(j_calls->handle_node_announcement_meth);
4870                 js_free(j_calls->handle_channel_announcement_meth);
4871                 js_free(j_calls->handle_channel_update_meth);
4872                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
4873                 js_free(j_calls->get_next_channel_announcements_meth);
4874                 js_free(j_calls->get_next_node_announcements_meth);
4875                 js_free(j_calls->sync_routing_table_meth);
4876                 js_free(j_calls->handle_reply_channel_range_meth);
4877                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
4878                 js_free(j_calls->handle_query_channel_range_meth);
4879                 js_free(j_calls->handle_query_short_channel_ids_meth);
4880                 FREE(j_calls);
4881         }
4882 }
4883 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
4884         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4885         LDKNodeAnnouncement msg_var = *msg;
4886         msg_var = NodeAnnouncement_clone(msg);
4887         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4888         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4889         long msg_ref = (long)msg_var.inner;
4890         if (msg_var.is_owned) {
4891                 msg_ref |= 1;
4892         }
4893         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
4894         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4895         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4896         return ret_conv;
4897 }
4898 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
4899         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4900         LDKChannelAnnouncement msg_var = *msg;
4901         msg_var = ChannelAnnouncement_clone(msg);
4902         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4903         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4904         long msg_ref = (long)msg_var.inner;
4905         if (msg_var.is_owned) {
4906                 msg_ref |= 1;
4907         }
4908         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
4909         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4910         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4911         return ret_conv;
4912 }
4913 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
4914         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4915         LDKChannelUpdate msg_var = *msg;
4916         msg_var = ChannelUpdate_clone(msg);
4917         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4918         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4919         long msg_ref = (long)msg_var.inner;
4920         if (msg_var.is_owned) {
4921                 msg_ref |= 1;
4922         }
4923         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
4924         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
4925         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
4926         return ret_conv;
4927 }
4928 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
4929         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4930         long ret_update = (long)update;
4931         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
4932 }
4933 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
4934         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4935         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
4936         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
4937         ret_constr.datalen = *((uint32_t*)ret);
4938         if (ret_constr.datalen > 0)
4939                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4940         else
4941                 ret_constr.data = NULL;
4942         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4943         for (size_t l = 0; l < ret_constr.datalen; l++) {
4944                 uint32_t ret_conv_63 = ret_vals[l];
4945                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
4946                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ret_conv_63);
4947                 ret_constr.data[l] = ret_conv_63_conv;
4948         }
4949         return ret_constr;
4950 }
4951 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
4952         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4953         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4954         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
4955         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
4956         LDKCVec_NodeAnnouncementZ ret_constr;
4957         ret_constr.datalen = *((uint32_t*)ret);
4958         if (ret_constr.datalen > 0)
4959                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4960         else
4961                 ret_constr.data = NULL;
4962         uint32_t* ret_vals = (uint32_t*)(ret + 4);
4963         for (size_t s = 0; s < ret_constr.datalen; s++) {
4964                 uint32_t ret_conv_18 = ret_vals[s];
4965                 LDKNodeAnnouncement ret_conv_18_conv;
4966                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
4967                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
4968                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
4969                 ret_constr.data[s] = ret_conv_18_conv;
4970         }
4971         return ret_constr;
4972 }
4973 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
4974         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4975         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4976         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4977         LDKInit init_var = *init;
4978         init_var = Init_clone(init);
4979         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4980         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4981         long init_ref = (long)init_var.inner;
4982         if (init_var.is_owned) {
4983                 init_ref |= 1;
4984         }
4985         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
4986 }
4987 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
4988         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4989         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4990         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4991         LDKReplyChannelRange msg_var = msg;
4992         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4993         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4994         long msg_ref = (long)msg_var.inner;
4995         if (msg_var.is_owned) {
4996                 msg_ref |= 1;
4997         }
4998         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
4999         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5000         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5001         return ret_conv;
5002 }
5003 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
5004         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5005         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5006         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5007         LDKReplyShortChannelIdsEnd msg_var = msg;
5008         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5009         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5010         long msg_ref = (long)msg_var.inner;
5011         if (msg_var.is_owned) {
5012                 msg_ref |= 1;
5013         }
5014         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
5015         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5016         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5017         return ret_conv;
5018 }
5019 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
5020         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5021         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5022         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5023         LDKQueryChannelRange msg_var = msg;
5024         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5025         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5026         long msg_ref = (long)msg_var.inner;
5027         if (msg_var.is_owned) {
5028                 msg_ref |= 1;
5029         }
5030         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
5031         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5032         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5033         return ret_conv;
5034 }
5035 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
5036         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5037         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5038         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5039         LDKQueryShortChannelIds msg_var = msg;
5040         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5041         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5042         long msg_ref = (long)msg_var.inner;
5043         if (msg_var.is_owned) {
5044                 msg_ref |= 1;
5045         }
5046         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
5047         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
5048         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
5049         return ret_conv;
5050 }
5051 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
5052         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
5053         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5054         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
5055         return (void*) this_arg;
5056 }
5057 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
5058         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
5059         atomic_init(&calls->refcnt, 1);
5060         //TODO: Assign calls->o from o
5061
5062         LDKRoutingMessageHandler ret = {
5063                 .this_arg = (void*) calls,
5064                 .handle_node_announcement = handle_node_announcement_jcall,
5065                 .handle_channel_announcement = handle_channel_announcement_jcall,
5066                 .handle_channel_update = handle_channel_update_jcall,
5067                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
5068                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
5069                 .get_next_node_announcements = get_next_node_announcements_jcall,
5070                 .sync_routing_table = sync_routing_table_jcall,
5071                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
5072                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
5073                 .handle_query_channel_range = handle_query_channel_range_jcall,
5074                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
5075                 .free = LDKRoutingMessageHandler_JCalls_free,
5076                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
5077         };
5078         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
5079         return ret;
5080 }
5081 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
5082         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
5083         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
5084         return (long)res_ptr;
5085 }
5086 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
5087         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5088         LDKNodeAnnouncement msg_conv;
5089         msg_conv.inner = (void*)(msg & (~1));
5090         msg_conv.is_owned = false;
5091         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5092         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
5093         return (long)ret_conv;
5094 }
5095
5096 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
5097         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5098         LDKChannelAnnouncement msg_conv;
5099         msg_conv.inner = (void*)(msg & (~1));
5100         msg_conv.is_owned = false;
5101         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5102         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5103         return (long)ret_conv;
5104 }
5105
5106 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
5107         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5108         LDKChannelUpdate msg_conv;
5109         msg_conv.inner = (void*)(msg & (~1));
5110         msg_conv.is_owned = false;
5111         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5112         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
5113         return (long)ret_conv;
5114 }
5115
5116 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
5117         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5118         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
5119         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
5120 }
5121
5122 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
5123         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5124         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
5125         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5126         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5127         for (size_t l = 0; l < ret_var.datalen; l++) {
5128                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5129                 *ret_conv_63_ref = ret_var.data[l];
5130                 ret_arr_ptr[l] = (long)ret_conv_63_ref;
5131         }
5132         FREE(ret_var.data);
5133         return ret_arr;
5134 }
5135
5136 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
5137         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5138         LDKPublicKey starting_point_ref;
5139         CHECK(*((uint32_t*)starting_point) == 33);
5140         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
5141         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
5142         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5143         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5144         for (size_t s = 0; s < ret_var.datalen; s++) {
5145                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
5146                 CHECK((((long)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5147                 CHECK((((long)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5148                 long ret_conv_18_ref = (long)ret_conv_18_var.inner;
5149                 if (ret_conv_18_var.is_owned) {
5150                         ret_conv_18_ref |= 1;
5151                 }
5152                 ret_arr_ptr[s] = ret_conv_18_ref;
5153         }
5154         FREE(ret_var.data);
5155         return ret_arr;
5156 }
5157
5158 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
5159         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5160         LDKPublicKey their_node_id_ref;
5161         CHECK(*((uint32_t*)their_node_id) == 33);
5162         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5163         LDKInit init_conv;
5164         init_conv.inner = (void*)(init & (~1));
5165         init_conv.is_owned = false;
5166         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
5167 }
5168
5169 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5170         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5171         LDKPublicKey their_node_id_ref;
5172         CHECK(*((uint32_t*)their_node_id) == 33);
5173         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5174         LDKReplyChannelRange msg_conv;
5175         msg_conv.inner = (void*)(msg & (~1));
5176         msg_conv.is_owned = (msg & 1) || (msg == 0);
5177         msg_conv = ReplyChannelRange_clone(&msg_conv);
5178         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5179         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5180         return (long)ret_conv;
5181 }
5182
5183 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) {
5184         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5185         LDKPublicKey their_node_id_ref;
5186         CHECK(*((uint32_t*)their_node_id) == 33);
5187         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5188         LDKReplyShortChannelIdsEnd msg_conv;
5189         msg_conv.inner = (void*)(msg & (~1));
5190         msg_conv.is_owned = (msg & 1) || (msg == 0);
5191         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
5192         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5193         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5194         return (long)ret_conv;
5195 }
5196
5197 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5198         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5199         LDKPublicKey their_node_id_ref;
5200         CHECK(*((uint32_t*)their_node_id) == 33);
5201         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5202         LDKQueryChannelRange msg_conv;
5203         msg_conv.inner = (void*)(msg & (~1));
5204         msg_conv.is_owned = (msg & 1) || (msg == 0);
5205         msg_conv = QueryChannelRange_clone(&msg_conv);
5206         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5207         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5208         return (long)ret_conv;
5209 }
5210
5211 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
5212         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
5213         LDKPublicKey their_node_id_ref;
5214         CHECK(*((uint32_t*)their_node_id) == 33);
5215         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
5216         LDKQueryShortChannelIds msg_conv;
5217         msg_conv.inner = (void*)(msg & (~1));
5218         msg_conv.is_owned = (msg & 1) || (msg == 0);
5219         msg_conv = QueryShortChannelIds_clone(&msg_conv);
5220         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5221         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
5222         return (long)ret_conv;
5223 }
5224
5225 typedef struct LDKSocketDescriptor_JCalls {
5226         atomic_size_t refcnt;
5227         uint32_t send_data_meth;
5228         uint32_t disconnect_socket_meth;
5229         uint32_t eq_meth;
5230         uint32_t hash_meth;
5231 } LDKSocketDescriptor_JCalls;
5232 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
5233         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5234         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5235                 js_free(j_calls->send_data_meth);
5236                 js_free(j_calls->disconnect_socket_meth);
5237                 js_free(j_calls->eq_meth);
5238                 js_free(j_calls->hash_meth);
5239                 FREE(j_calls);
5240         }
5241 }
5242 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
5243         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5244         LDKu8slice data_var = data;
5245         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5246         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
5247         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
5248 }
5249 void disconnect_socket_jcall(void* this_arg) {
5250         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5251         js_invoke_function_0(j_calls->disconnect_socket_meth);
5252 }
5253 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
5254         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5255         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5256         *other_arg_clone = SocketDescriptor_clone(other_arg);
5257         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
5258 }
5259 uint64_t hash_jcall(const void* this_arg) {
5260         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5261         return js_invoke_function_0(j_calls->hash_meth);
5262 }
5263 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
5264         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
5265         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5266         return (void*) this_arg;
5267 }
5268 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
5269         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
5270         atomic_init(&calls->refcnt, 1);
5271         //TODO: Assign calls->o from o
5272
5273         LDKSocketDescriptor ret = {
5274                 .this_arg = (void*) calls,
5275                 .send_data = send_data_jcall,
5276                 .disconnect_socket = disconnect_socket_jcall,
5277                 .eq = eq_jcall,
5278                 .hash = hash_jcall,
5279                 .clone = LDKSocketDescriptor_JCalls_clone,
5280                 .free = LDKSocketDescriptor_JCalls_free,
5281         };
5282         return ret;
5283 }
5284 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
5285         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
5286         *res_ptr = LDKSocketDescriptor_init(o);
5287         return (long)res_ptr;
5288 }
5289 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
5290         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5291         LDKu8slice data_ref;
5292         data_ref.datalen = *((uint32_t*)data);
5293         data_ref.data = (int8_t*)(data + 4);
5294         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
5295         return ret_val;
5296 }
5297
5298 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
5299         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5300         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
5301 }
5302
5303 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
5304         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
5305         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
5306         return ret_val;
5307 }
5308
5309 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
5310         LDKTransaction _res_ref;
5311         _res_ref.datalen = *((uint32_t*)_res);
5312         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
5313         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5314         _res_ref.data_is_owned = true;
5315         Transaction_free(_res_ref);
5316 }
5317
5318 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
5319         if ((_res & 1) != 0) return;
5320         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
5321         FREE((void*)_res);
5322         TxOut_free(_res_conv);
5323 }
5324
5325 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
5326         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
5327         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5328         *ret_ref = TxOut_clone(orig_conv);
5329         return (long)ret_ref;
5330 }
5331
5332 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
5333         LDKSecretKey o_ref;
5334         CHECK(*((uint32_t*)o) == 32);
5335         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5336         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5337         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
5338         return (long)ret_conv;
5339 }
5340
5341 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
5342         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5343         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
5344         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
5345         return (long)ret_conv;
5346 }
5347
5348 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
5349         if ((_res & 1) != 0) return;
5350         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
5351         FREE((void*)_res);
5352         CResult_SecretKeyErrorZ_free(_res_conv);
5353 }
5354
5355 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
5356         LDKPublicKey o_ref;
5357         CHECK(*((uint32_t*)o) == 33);
5358         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5359         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5360         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
5361         return (long)ret_conv;
5362 }
5363
5364 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
5365         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5366         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
5367         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
5368         return (long)ret_conv;
5369 }
5370
5371 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
5372         if ((_res & 1) != 0) return;
5373         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
5374         FREE((void*)_res);
5375         CResult_PublicKeyErrorZ_free(_res_conv);
5376 }
5377
5378 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
5379         LDKTxCreationKeys o_conv;
5380         o_conv.inner = (void*)(o & (~1));
5381         o_conv.is_owned = (o & 1) || (o == 0);
5382         o_conv = TxCreationKeys_clone(&o_conv);
5383         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5384         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
5385         return (long)ret_conv;
5386 }
5387
5388 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
5389         LDKDecodeError e_conv;
5390         e_conv.inner = (void*)(e & (~1));
5391         e_conv.is_owned = (e & 1) || (e == 0);
5392         e_conv = DecodeError_clone(&e_conv);
5393         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5394         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
5395         return (long)ret_conv;
5396 }
5397
5398 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
5399         if ((_res & 1) != 0) return;
5400         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5401         FREE((void*)_res);
5402         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
5403 }
5404
5405 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
5406         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
5407         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
5408         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
5409         return (long)ret_conv;
5410 }
5411
5412 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
5413         LDKChannelPublicKeys o_conv;
5414         o_conv.inner = (void*)(o & (~1));
5415         o_conv.is_owned = (o & 1) || (o == 0);
5416         o_conv = ChannelPublicKeys_clone(&o_conv);
5417         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5418         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
5419         return (long)ret_conv;
5420 }
5421
5422 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
5423         LDKDecodeError e_conv;
5424         e_conv.inner = (void*)(e & (~1));
5425         e_conv.is_owned = (e & 1) || (e == 0);
5426         e_conv = DecodeError_clone(&e_conv);
5427         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5428         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
5429         return (long)ret_conv;
5430 }
5431
5432 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
5433         if ((_res & 1) != 0) return;
5434         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
5435         FREE((void*)_res);
5436         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
5437 }
5438
5439 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
5440         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
5441         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
5442         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
5443         return (long)ret_conv;
5444 }
5445
5446 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
5447         LDKTxCreationKeys o_conv;
5448         o_conv.inner = (void*)(o & (~1));
5449         o_conv.is_owned = (o & 1) || (o == 0);
5450         o_conv = TxCreationKeys_clone(&o_conv);
5451         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5452         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
5453         return (long)ret_conv;
5454 }
5455
5456 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
5457         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5458         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
5459         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
5460         return (long)ret_conv;
5461 }
5462
5463 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
5464         if ((_res & 1) != 0) return;
5465         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
5466         FREE((void*)_res);
5467         CResult_TxCreationKeysErrorZ_free(_res_conv);
5468 }
5469
5470 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
5471         LDKHTLCOutputInCommitment o_conv;
5472         o_conv.inner = (void*)(o & (~1));
5473         o_conv.is_owned = (o & 1) || (o == 0);
5474         o_conv = HTLCOutputInCommitment_clone(&o_conv);
5475         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5476         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
5477         return (long)ret_conv;
5478 }
5479
5480 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
5481         LDKDecodeError e_conv;
5482         e_conv.inner = (void*)(e & (~1));
5483         e_conv.is_owned = (e & 1) || (e == 0);
5484         e_conv = DecodeError_clone(&e_conv);
5485         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5486         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
5487         return (long)ret_conv;
5488 }
5489
5490 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
5491         if ((_res & 1) != 0) return;
5492         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
5493         FREE((void*)_res);
5494         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
5495 }
5496
5497 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
5498         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
5499         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
5500         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
5501         return (long)ret_conv;
5502 }
5503
5504 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5505         LDKCounterpartyChannelTransactionParameters o_conv;
5506         o_conv.inner = (void*)(o & (~1));
5507         o_conv.is_owned = (o & 1) || (o == 0);
5508         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
5509         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5510         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5511         return (long)ret_conv;
5512 }
5513
5514 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5515         LDKDecodeError e_conv;
5516         e_conv.inner = (void*)(e & (~1));
5517         e_conv.is_owned = (e & 1) || (e == 0);
5518         e_conv = DecodeError_clone(&e_conv);
5519         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5520         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
5521         return (long)ret_conv;
5522 }
5523
5524 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5525         if ((_res & 1) != 0) return;
5526         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5527         FREE((void*)_res);
5528         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5529 }
5530
5531 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5532         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5533         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
5534         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5535         return (long)ret_conv;
5536 }
5537
5538 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
5539         LDKChannelTransactionParameters o_conv;
5540         o_conv.inner = (void*)(o & (~1));
5541         o_conv.is_owned = (o & 1) || (o == 0);
5542         o_conv = ChannelTransactionParameters_clone(&o_conv);
5543         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5544         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
5545         return (long)ret_conv;
5546 }
5547
5548 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
5549         LDKDecodeError e_conv;
5550         e_conv.inner = (void*)(e & (~1));
5551         e_conv.is_owned = (e & 1) || (e == 0);
5552         e_conv = DecodeError_clone(&e_conv);
5553         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5554         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
5555         return (long)ret_conv;
5556 }
5557
5558 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
5559         if ((_res & 1) != 0) return;
5560         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
5561         FREE((void*)_res);
5562         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
5563 }
5564
5565 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
5566         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
5567         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
5568         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
5569         return (long)ret_conv;
5570 }
5571
5572 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
5573         LDKCVec_SignatureZ _res_constr;
5574         _res_constr.datalen = *((uint32_t*)_res);
5575         if (_res_constr.datalen > 0)
5576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5577         else
5578                 _res_constr.data = NULL;
5579         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5580         for (size_t m = 0; m < _res_constr.datalen; m++) {
5581                 int8_tArray _res_conv_12 = _res_vals[m];
5582                 LDKSignature _res_conv_12_ref;
5583                 CHECK(*((uint32_t*)_res_conv_12) == 64);
5584                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
5585                 _res_constr.data[m] = _res_conv_12_ref;
5586         }
5587         CVec_SignatureZ_free(_res_constr);
5588 }
5589
5590 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5591         LDKHolderCommitmentTransaction o_conv;
5592         o_conv.inner = (void*)(o & (~1));
5593         o_conv.is_owned = (o & 1) || (o == 0);
5594         o_conv = HolderCommitmentTransaction_clone(&o_conv);
5595         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5596         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
5597         return (long)ret_conv;
5598 }
5599
5600 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5601         LDKDecodeError e_conv;
5602         e_conv.inner = (void*)(e & (~1));
5603         e_conv.is_owned = (e & 1) || (e == 0);
5604         e_conv = DecodeError_clone(&e_conv);
5605         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5606         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
5607         return (long)ret_conv;
5608 }
5609
5610 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5611         if ((_res & 1) != 0) return;
5612         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5613         FREE((void*)_res);
5614         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
5615 }
5616
5617 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5618         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5619         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
5620         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5621         return (long)ret_conv;
5622 }
5623
5624 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5625         LDKBuiltCommitmentTransaction o_conv;
5626         o_conv.inner = (void*)(o & (~1));
5627         o_conv.is_owned = (o & 1) || (o == 0);
5628         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
5629         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5630         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
5631         return (long)ret_conv;
5632 }
5633
5634 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5635         LDKDecodeError e_conv;
5636         e_conv.inner = (void*)(e & (~1));
5637         e_conv.is_owned = (e & 1) || (e == 0);
5638         e_conv = DecodeError_clone(&e_conv);
5639         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5640         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
5641         return (long)ret_conv;
5642 }
5643
5644 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5645         if ((_res & 1) != 0) return;
5646         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5647         FREE((void*)_res);
5648         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
5649 }
5650
5651 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5652         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
5653         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
5654         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
5655         return (long)ret_conv;
5656 }
5657
5658 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
5659         LDKCommitmentTransaction o_conv;
5660         o_conv.inner = (void*)(o & (~1));
5661         o_conv.is_owned = (o & 1) || (o == 0);
5662         o_conv = CommitmentTransaction_clone(&o_conv);
5663         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5664         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
5665         return (long)ret_conv;
5666 }
5667
5668 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
5669         LDKDecodeError e_conv;
5670         e_conv.inner = (void*)(e & (~1));
5671         e_conv.is_owned = (e & 1) || (e == 0);
5672         e_conv = DecodeError_clone(&e_conv);
5673         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5674         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
5675         return (long)ret_conv;
5676 }
5677
5678 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
5679         if ((_res & 1) != 0) return;
5680         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
5681         FREE((void*)_res);
5682         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
5683 }
5684
5685 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
5686         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
5687         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
5688         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
5689         return (long)ret_conv;
5690 }
5691
5692 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
5693         LDKTrustedCommitmentTransaction o_conv;
5694         o_conv.inner = (void*)(o & (~1));
5695         o_conv.is_owned = (o & 1) || (o == 0);
5696         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
5697         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5698         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5699         return (long)ret_conv;
5700 }
5701
5702 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
5703         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5704         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5705         return (long)ret_conv;
5706 }
5707
5708 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
5709         if ((_res & 1) != 0) return;
5710         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
5711         FREE((void*)_res);
5712         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5713 }
5714
5715 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
5716         LDKCVec_SignatureZ o_constr;
5717         o_constr.datalen = *((uint32_t*)o);
5718         if (o_constr.datalen > 0)
5719                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5720         else
5721                 o_constr.data = NULL;
5722         int8_tArray* o_vals = (int8_tArray*)(o + 4);
5723         for (size_t m = 0; m < o_constr.datalen; m++) {
5724                 int8_tArray o_conv_12 = o_vals[m];
5725                 LDKSignature o_conv_12_ref;
5726                 CHECK(*((uint32_t*)o_conv_12) == 64);
5727                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
5728                 o_constr.data[m] = o_conv_12_ref;
5729         }
5730         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5731         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
5732         return (long)ret_conv;
5733 }
5734
5735 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
5736         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5737         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
5738         return (long)ret_conv;
5739 }
5740
5741 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5742         if ((_res & 1) != 0) return;
5743         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
5744         FREE((void*)_res);
5745         CResult_CVec_SignatureZNoneZ_free(_res_conv);
5746 }
5747
5748 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
5749         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
5750         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5751         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
5752         return (long)ret_conv;
5753 }
5754
5755 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
5756         LDKCVec_MessageSendEventZ _res_constr;
5757         _res_constr.datalen = *((uint32_t*)_res);
5758         if (_res_constr.datalen > 0)
5759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5760         else
5761                 _res_constr.data = NULL;
5762         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5763         for (size_t s = 0; s < _res_constr.datalen; s++) {
5764                 uint32_t _res_conv_18 = _res_vals[s];
5765                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
5766                 FREE((void*)_res_conv_18);
5767                 _res_constr.data[s] = _res_conv_18_conv;
5768         }
5769         CVec_MessageSendEventZ_free(_res_constr);
5770 }
5771
5772 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5773         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5774         *ret_conv = CResult_boolLightningErrorZ_ok(o);
5775         return (long)ret_conv;
5776 }
5777
5778 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5779         LDKLightningError e_conv;
5780         e_conv.inner = (void*)(e & (~1));
5781         e_conv.is_owned = (e & 1) || (e == 0);
5782         e_conv = LightningError_clone(&e_conv);
5783         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5784         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5785         return (long)ret_conv;
5786 }
5787
5788 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5789         if ((_res & 1) != 0) return;
5790         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
5791         FREE((void*)_res);
5792         CResult_boolLightningErrorZ_free(_res_conv);
5793 }
5794
5795 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
5796         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
5797         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5798         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
5799         return (long)ret_conv;
5800 }
5801
5802 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
5803         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
5804         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5805         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
5806         return (long)ret_ref;
5807 }
5808
5809 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5810         LDKChannelAnnouncement a_conv;
5811         a_conv.inner = (void*)(a & (~1));
5812         a_conv.is_owned = (a & 1) || (a == 0);
5813         a_conv = ChannelAnnouncement_clone(&a_conv);
5814         LDKChannelUpdate b_conv;
5815         b_conv.inner = (void*)(b & (~1));
5816         b_conv.is_owned = (b & 1) || (b == 0);
5817         b_conv = ChannelUpdate_clone(&b_conv);
5818         LDKChannelUpdate c_conv;
5819         c_conv.inner = (void*)(c & (~1));
5820         c_conv.is_owned = (c & 1) || (c == 0);
5821         c_conv = ChannelUpdate_clone(&c_conv);
5822         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5823         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5824         return (long)ret_ref;
5825 }
5826
5827 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5828         if ((_res & 1) != 0) return;
5829         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
5830         FREE((void*)_res);
5831         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5832 }
5833
5834 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5835         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5836         _res_constr.datalen = *((uint32_t*)_res);
5837         if (_res_constr.datalen > 0)
5838                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5839         else
5840                 _res_constr.data = NULL;
5841         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5842         for (size_t l = 0; l < _res_constr.datalen; l++) {
5843                 uint32_t _res_conv_63 = _res_vals[l];
5844                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
5845                 FREE((void*)_res_conv_63);
5846                 _res_constr.data[l] = _res_conv_63_conv;
5847         }
5848         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5849 }
5850
5851 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5852         LDKCVec_NodeAnnouncementZ _res_constr;
5853         _res_constr.datalen = *((uint32_t*)_res);
5854         if (_res_constr.datalen > 0)
5855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5856         else
5857                 _res_constr.data = NULL;
5858         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5859         for (size_t s = 0; s < _res_constr.datalen; s++) {
5860                 uint32_t _res_conv_18 = _res_vals[s];
5861                 LDKNodeAnnouncement _res_conv_18_conv;
5862                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
5863                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
5864                 _res_constr.data[s] = _res_conv_18_conv;
5865         }
5866         CVec_NodeAnnouncementZ_free(_res_constr);
5867 }
5868
5869 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
5870         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5871         *ret_conv = CResult_NoneLightningErrorZ_ok();
5872         return (long)ret_conv;
5873 }
5874
5875 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
5876         LDKLightningError e_conv;
5877         e_conv.inner = (void*)(e & (~1));
5878         e_conv.is_owned = (e & 1) || (e == 0);
5879         e_conv = LightningError_clone(&e_conv);
5880         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5881         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
5882         return (long)ret_conv;
5883 }
5884
5885 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
5886         if ((_res & 1) != 0) return;
5887         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
5888         FREE((void*)_res);
5889         CResult_NoneLightningErrorZ_free(_res_conv);
5890 }
5891
5892 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
5893         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
5894         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5895         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
5896         return (long)ret_conv;
5897 }
5898
5899 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
5900         LDKCVec_PublicKeyZ _res_constr;
5901         _res_constr.datalen = *((uint32_t*)_res);
5902         if (_res_constr.datalen > 0)
5903                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
5904         else
5905                 _res_constr.data = NULL;
5906         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5907         for (size_t m = 0; m < _res_constr.datalen; m++) {
5908                 int8_tArray _res_conv_12 = _res_vals[m];
5909                 LDKPublicKey _res_conv_12_ref;
5910                 CHECK(*((uint32_t*)_res_conv_12) == 33);
5911                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
5912                 _res_constr.data[m] = _res_conv_12_ref;
5913         }
5914         CVec_PublicKeyZ_free(_res_constr);
5915 }
5916
5917 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
5918         LDKCVec_u8Z _res_ref;
5919         _res_ref.datalen = *((uint32_t*)_res);
5920         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
5921         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5922         CVec_u8Z_free(_res_ref);
5923 }
5924
5925 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
5926         LDKCVec_u8Z o_ref;
5927         o_ref.datalen = *((uint32_t*)o);
5928         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
5929         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
5930         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5931         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
5932         return (long)ret_conv;
5933 }
5934
5935 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
5936         LDKPeerHandleError e_conv;
5937         e_conv.inner = (void*)(e & (~1));
5938         e_conv.is_owned = (e & 1) || (e == 0);
5939         e_conv = PeerHandleError_clone(&e_conv);
5940         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5941         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
5942         return (long)ret_conv;
5943 }
5944
5945 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
5946         if ((_res & 1) != 0) return;
5947         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5948         FREE((void*)_res);
5949         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
5950 }
5951
5952 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
5953         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
5954         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5955         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
5956         return (long)ret_conv;
5957 }
5958
5959 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
5960         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5961         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
5962         return (long)ret_conv;
5963 }
5964
5965 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
5966         LDKPeerHandleError e_conv;
5967         e_conv.inner = (void*)(e & (~1));
5968         e_conv.is_owned = (e & 1) || (e == 0);
5969         e_conv = PeerHandleError_clone(&e_conv);
5970         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5971         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
5972         return (long)ret_conv;
5973 }
5974
5975 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
5976         if ((_res & 1) != 0) return;
5977         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5978         FREE((void*)_res);
5979         CResult_NonePeerHandleErrorZ_free(_res_conv);
5980 }
5981
5982 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
5983         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
5984         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5985         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
5986         return (long)ret_conv;
5987 }
5988
5989 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
5990         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5991         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
5992         return (long)ret_conv;
5993 }
5994
5995 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
5996         LDKPeerHandleError e_conv;
5997         e_conv.inner = (void*)(e & (~1));
5998         e_conv.is_owned = (e & 1) || (e == 0);
5999         e_conv = PeerHandleError_clone(&e_conv);
6000         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6001         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
6002         return (long)ret_conv;
6003 }
6004
6005 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
6006         if ((_res & 1) != 0) return;
6007         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
6008         FREE((void*)_res);
6009         CResult_boolPeerHandleErrorZ_free(_res_conv);
6010 }
6011
6012 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
6013         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
6014         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
6015         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
6016         return (long)ret_conv;
6017 }
6018
6019 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
6020         LDKInitFeatures o_conv;
6021         o_conv.inner = (void*)(o & (~1));
6022         o_conv.is_owned = (o & 1) || (o == 0);
6023         o_conv = InitFeatures_clone(&o_conv);
6024         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6025         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
6026         return (long)ret_conv;
6027 }
6028
6029 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
6030         LDKDecodeError e_conv;
6031         e_conv.inner = (void*)(e & (~1));
6032         e_conv.is_owned = (e & 1) || (e == 0);
6033         e_conv = DecodeError_clone(&e_conv);
6034         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
6035         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
6036         return (long)ret_conv;
6037 }
6038
6039 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
6040         if ((_res & 1) != 0) return;
6041         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6042         FREE((void*)_res);
6043         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
6044 }
6045
6046 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
6047         LDKNodeFeatures o_conv;
6048         o_conv.inner = (void*)(o & (~1));
6049         o_conv.is_owned = (o & 1) || (o == 0);
6050         o_conv = NodeFeatures_clone(&o_conv);
6051         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6052         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
6053         return (long)ret_conv;
6054 }
6055
6056 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
6057         LDKDecodeError e_conv;
6058         e_conv.inner = (void*)(e & (~1));
6059         e_conv.is_owned = (e & 1) || (e == 0);
6060         e_conv = DecodeError_clone(&e_conv);
6061         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
6062         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
6063         return (long)ret_conv;
6064 }
6065
6066 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
6067         if ((_res & 1) != 0) return;
6068         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6069         FREE((void*)_res);
6070         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
6071 }
6072
6073 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
6074         LDKChannelFeatures o_conv;
6075         o_conv.inner = (void*)(o & (~1));
6076         o_conv.is_owned = (o & 1) || (o == 0);
6077         o_conv = ChannelFeatures_clone(&o_conv);
6078         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6079         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
6080         return (long)ret_conv;
6081 }
6082
6083 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
6084         LDKDecodeError e_conv;
6085         e_conv.inner = (void*)(e & (~1));
6086         e_conv.is_owned = (e & 1) || (e == 0);
6087         e_conv = DecodeError_clone(&e_conv);
6088         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
6089         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
6090         return (long)ret_conv;
6091 }
6092
6093 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
6094         if ((_res & 1) != 0) return;
6095         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6096         FREE((void*)_res);
6097         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
6098 }
6099
6100 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
6101         LDKInvoiceFeatures o_conv;
6102         o_conv.inner = (void*)(o & (~1));
6103         o_conv.is_owned = (o & 1) || (o == 0);
6104         o_conv = InvoiceFeatures_clone(&o_conv);
6105         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
6106         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
6107         return (long)ret_conv;
6108 }
6109
6110 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
6111         LDKDecodeError e_conv;
6112         e_conv.inner = (void*)(e & (~1));
6113         e_conv.is_owned = (e & 1) || (e == 0);
6114         e_conv = DecodeError_clone(&e_conv);
6115         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
6116         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
6117         return (long)ret_conv;
6118 }
6119
6120 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
6121         if ((_res & 1) != 0) return;
6122         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6123         FREE((void*)_res);
6124         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
6125 }
6126
6127 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
6128         LDKChannelConfig o_conv;
6129         o_conv.inner = (void*)(o & (~1));
6130         o_conv.is_owned = (o & 1) || (o == 0);
6131         o_conv = ChannelConfig_clone(&o_conv);
6132         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6133         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
6134         return (long)ret_conv;
6135 }
6136
6137 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
6138         LDKDecodeError e_conv;
6139         e_conv.inner = (void*)(e & (~1));
6140         e_conv.is_owned = (e & 1) || (e == 0);
6141         e_conv = DecodeError_clone(&e_conv);
6142         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6143         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
6144         return (long)ret_conv;
6145 }
6146
6147 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
6148         if ((_res & 1) != 0) return;
6149         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
6150         FREE((void*)_res);
6151         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
6152 }
6153
6154 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
6155         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
6156         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
6157         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
6158         return (long)ret_conv;
6159 }
6160
6161 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
6162         LDKDirectionalChannelInfo o_conv;
6163         o_conv.inner = (void*)(o & (~1));
6164         o_conv.is_owned = (o & 1) || (o == 0);
6165         o_conv = DirectionalChannelInfo_clone(&o_conv);
6166         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6167         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
6168         return (long)ret_conv;
6169 }
6170
6171 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
6172         LDKDecodeError e_conv;
6173         e_conv.inner = (void*)(e & (~1));
6174         e_conv.is_owned = (e & 1) || (e == 0);
6175         e_conv = DecodeError_clone(&e_conv);
6176         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6177         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
6178         return (long)ret_conv;
6179 }
6180
6181 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
6182         if ((_res & 1) != 0) return;
6183         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6184         FREE((void*)_res);
6185         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
6186 }
6187
6188 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6189         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
6190         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
6191         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
6192         return (long)ret_conv;
6193 }
6194
6195 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
6196         LDKChannelInfo o_conv;
6197         o_conv.inner = (void*)(o & (~1));
6198         o_conv.is_owned = (o & 1) || (o == 0);
6199         o_conv = ChannelInfo_clone(&o_conv);
6200         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6201         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
6202         return (long)ret_conv;
6203 }
6204
6205 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
6206         LDKDecodeError e_conv;
6207         e_conv.inner = (void*)(e & (~1));
6208         e_conv.is_owned = (e & 1) || (e == 0);
6209         e_conv = DecodeError_clone(&e_conv);
6210         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6211         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
6212         return (long)ret_conv;
6213 }
6214
6215 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
6216         if ((_res & 1) != 0) return;
6217         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6218         FREE((void*)_res);
6219         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
6220 }
6221
6222 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
6223         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
6224         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
6225         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
6226         return (long)ret_conv;
6227 }
6228
6229 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6230         LDKRoutingFees o_conv;
6231         o_conv.inner = (void*)(o & (~1));
6232         o_conv.is_owned = (o & 1) || (o == 0);
6233         o_conv = RoutingFees_clone(&o_conv);
6234         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6235         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6236         return (long)ret_conv;
6237 }
6238
6239 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6240         LDKDecodeError e_conv;
6241         e_conv.inner = (void*)(e & (~1));
6242         e_conv.is_owned = (e & 1) || (e == 0);
6243         e_conv = DecodeError_clone(&e_conv);
6244         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6245         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6246         return (long)ret_conv;
6247 }
6248
6249 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6250         if ((_res & 1) != 0) return;
6251         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6252         FREE((void*)_res);
6253         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6254 }
6255
6256 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
6257         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
6258         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6259         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
6260         return (long)ret_conv;
6261 }
6262
6263 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
6264         LDKCVec_NetAddressZ _res_constr;
6265         _res_constr.datalen = *((uint32_t*)_res);
6266         if (_res_constr.datalen > 0)
6267                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6268         else
6269                 _res_constr.data = NULL;
6270         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6271         for (size_t m = 0; m < _res_constr.datalen; m++) {
6272                 uint32_t _res_conv_12 = _res_vals[m];
6273                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
6274                 FREE((void*)_res_conv_12);
6275                 _res_constr.data[m] = _res_conv_12_conv;
6276         }
6277         CVec_NetAddressZ_free(_res_constr);
6278 }
6279
6280 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6281         LDKNodeAnnouncementInfo o_conv;
6282         o_conv.inner = (void*)(o & (~1));
6283         o_conv.is_owned = (o & 1) || (o == 0);
6284         o_conv = NodeAnnouncementInfo_clone(&o_conv);
6285         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6286         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6287         return (long)ret_conv;
6288 }
6289
6290 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6291         LDKDecodeError e_conv;
6292         e_conv.inner = (void*)(e & (~1));
6293         e_conv.is_owned = (e & 1) || (e == 0);
6294         e_conv = DecodeError_clone(&e_conv);
6295         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6296         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6297         return (long)ret_conv;
6298 }
6299
6300 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6301         if ((_res & 1) != 0) return;
6302         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6303         FREE((void*)_res);
6304         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6305 }
6306
6307 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
6308         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
6309         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6310         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
6311         return (long)ret_conv;
6312 }
6313
6314 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
6315         LDKCVec_u64Z _res_constr;
6316         _res_constr.datalen = *((uint32_t*)_res);
6317         if (_res_constr.datalen > 0)
6318                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
6319         else
6320                 _res_constr.data = NULL;
6321         int64_t* _res_vals = (int64_t*)(_res + 4);
6322         for (size_t i = 0; i < _res_constr.datalen; i++) {
6323                 int64_t _res_conv_8 = _res_vals[i];
6324                 _res_constr.data[i] = _res_conv_8;
6325         }
6326         CVec_u64Z_free(_res_constr);
6327 }
6328
6329 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6330         LDKNodeInfo o_conv;
6331         o_conv.inner = (void*)(o & (~1));
6332         o_conv.is_owned = (o & 1) || (o == 0);
6333         o_conv = NodeInfo_clone(&o_conv);
6334         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6335         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6336         return (long)ret_conv;
6337 }
6338
6339 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6340         LDKDecodeError e_conv;
6341         e_conv.inner = (void*)(e & (~1));
6342         e_conv.is_owned = (e & 1) || (e == 0);
6343         e_conv = DecodeError_clone(&e_conv);
6344         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6345         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6346         return (long)ret_conv;
6347 }
6348
6349 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6350         if ((_res & 1) != 0) return;
6351         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6352         FREE((void*)_res);
6353         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6354 }
6355
6356 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
6357         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
6358         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6359         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
6360         return (long)ret_conv;
6361 }
6362
6363 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6364         LDKNetworkGraph o_conv;
6365         o_conv.inner = (void*)(o & (~1));
6366         o_conv.is_owned = (o & 1) || (o == 0);
6367         o_conv = NetworkGraph_clone(&o_conv);
6368         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6369         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6370         return (long)ret_conv;
6371 }
6372
6373 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6374         LDKDecodeError e_conv;
6375         e_conv.inner = (void*)(e & (~1));
6376         e_conv.is_owned = (e & 1) || (e == 0);
6377         e_conv = DecodeError_clone(&e_conv);
6378         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6379         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6380         return (long)ret_conv;
6381 }
6382
6383 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6384         if ((_res & 1) != 0) return;
6385         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
6386         FREE((void*)_res);
6387         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6388 }
6389
6390 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
6391         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
6392         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6393         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
6394         return (long)ret_conv;
6395 }
6396
6397 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
6398         LDKTransaction b_ref;
6399         b_ref.datalen = *((uint32_t*)b);
6400         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
6401         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6402         b_ref.data_is_owned = true;
6403         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6404         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
6405         return (long)ret_ref;
6406 }
6407
6408 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
6409         if ((_res & 1) != 0) return;
6410         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
6411         FREE((void*)_res);
6412         C2Tuple_usizeTransactionZ_free(_res_conv);
6413 }
6414
6415 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
6416         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
6417         _res_constr.datalen = *((uint32_t*)_res);
6418         if (_res_constr.datalen > 0)
6419                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6420         else
6421                 _res_constr.data = NULL;
6422         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6423         for (size_t e = 0; e < _res_constr.datalen; e++) {
6424                 uint32_t _res_conv_30 = _res_vals[e];
6425                 LDKC2Tuple_usizeTransactionZ _res_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_30) & ~1);
6426                 FREE((void*)_res_conv_30);
6427                 _res_constr.data[e] = _res_conv_30_conv;
6428         }
6429         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
6430 }
6431
6432 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
6433         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6434         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
6435         return (long)ret_conv;
6436 }
6437
6438 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
6439         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
6440         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6441         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
6442         return (long)ret_conv;
6443 }
6444
6445 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
6446         if ((_res & 1) != 0) return;
6447         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
6448         FREE((void*)_res);
6449         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
6450 }
6451
6452 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
6453         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
6454         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6455         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
6456         return (long)ret_conv;
6457 }
6458
6459 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
6460         LDKCVec_MonitorEventZ _res_constr;
6461         _res_constr.datalen = *((uint32_t*)_res);
6462         if (_res_constr.datalen > 0)
6463                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6464         else
6465                 _res_constr.data = NULL;
6466         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6467         for (size_t o = 0; o < _res_constr.datalen; o++) {
6468                 uint32_t _res_conv_14 = _res_vals[o];
6469                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
6470                 FREE((void*)_res_conv_14);
6471                 _res_constr.data[o] = _res_conv_14_conv;
6472         }
6473         CVec_MonitorEventZ_free(_res_constr);
6474 }
6475
6476 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
6477         LDKCVec_EventZ _res_constr;
6478         _res_constr.datalen = *((uint32_t*)_res);
6479         if (_res_constr.datalen > 0)
6480                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
6481         else
6482                 _res_constr.data = NULL;
6483         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6484         for (size_t h = 0; h < _res_constr.datalen; h++) {
6485                 uint32_t _res_conv_7 = _res_vals[h];
6486                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
6487                 FREE((void*)_res_conv_7);
6488                 _res_constr.data[h] = _res_conv_7_conv;
6489         }
6490         CVec_EventZ_free(_res_constr);
6491 }
6492
6493 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
6494         LDKOutPoint o_conv;
6495         o_conv.inner = (void*)(o & (~1));
6496         o_conv.is_owned = (o & 1) || (o == 0);
6497         o_conv = OutPoint_clone(&o_conv);
6498         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6499         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
6500         return (long)ret_conv;
6501 }
6502
6503 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
6504         LDKDecodeError e_conv;
6505         e_conv.inner = (void*)(e & (~1));
6506         e_conv.is_owned = (e & 1) || (e == 0);
6507         e_conv = DecodeError_clone(&e_conv);
6508         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6509         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
6510         return (long)ret_conv;
6511 }
6512
6513 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
6514         if ((_res & 1) != 0) return;
6515         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
6516         FREE((void*)_res);
6517         CResult_OutPointDecodeErrorZ_free(_res_conv);
6518 }
6519
6520 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
6521         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
6522         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
6523         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
6524         return (long)ret_conv;
6525 }
6526
6527 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
6528         LDKChannelMonitorUpdate o_conv;
6529         o_conv.inner = (void*)(o & (~1));
6530         o_conv.is_owned = (o & 1) || (o == 0);
6531         o_conv = ChannelMonitorUpdate_clone(&o_conv);
6532         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6533         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
6534         return (long)ret_conv;
6535 }
6536
6537 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
6538         LDKDecodeError e_conv;
6539         e_conv.inner = (void*)(e & (~1));
6540         e_conv.is_owned = (e & 1) || (e == 0);
6541         e_conv = DecodeError_clone(&e_conv);
6542         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6543         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
6544         return (long)ret_conv;
6545 }
6546
6547 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
6548         if ((_res & 1) != 0) return;
6549         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6550         FREE((void*)_res);
6551         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
6552 }
6553
6554 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
6555         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
6556         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6557         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
6558         return (long)ret_conv;
6559 }
6560
6561 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
6562         LDKHTLCUpdate o_conv;
6563         o_conv.inner = (void*)(o & (~1));
6564         o_conv.is_owned = (o & 1) || (o == 0);
6565         o_conv = HTLCUpdate_clone(&o_conv);
6566         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6567         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
6568         return (long)ret_conv;
6569 }
6570
6571 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
6572         LDKDecodeError e_conv;
6573         e_conv.inner = (void*)(e & (~1));
6574         e_conv.is_owned = (e & 1) || (e == 0);
6575         e_conv = DecodeError_clone(&e_conv);
6576         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6577         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
6578         return (long)ret_conv;
6579 }
6580
6581 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
6582         if ((_res & 1) != 0) return;
6583         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
6584         FREE((void*)_res);
6585         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
6586 }
6587
6588 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
6589         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
6590         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
6591         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
6592         return (long)ret_conv;
6593 }
6594
6595 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
6596         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6597         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
6598         return (long)ret_conv;
6599 }
6600
6601 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
6602         LDKMonitorUpdateError e_conv;
6603         e_conv.inner = (void*)(e & (~1));
6604         e_conv.is_owned = (e & 1) || (e == 0);
6605         e_conv = MonitorUpdateError_clone(&e_conv);
6606         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6607         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
6608         return (long)ret_conv;
6609 }
6610
6611 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
6612         if ((_res & 1) != 0) return;
6613         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
6614         FREE((void*)_res);
6615         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
6616 }
6617
6618 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
6619         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
6620         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6621         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
6622         return (long)ret_conv;
6623 }
6624
6625 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
6626         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
6627         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6628         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
6629         return (long)ret_ref;
6630 }
6631
6632 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
6633         LDKOutPoint a_conv;
6634         a_conv.inner = (void*)(a & (~1));
6635         a_conv.is_owned = (a & 1) || (a == 0);
6636         a_conv = OutPoint_clone(&a_conv);
6637         LDKCVec_u8Z b_ref;
6638         b_ref.datalen = *((uint32_t*)b);
6639         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6640         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6641         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6642         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
6643         return (long)ret_ref;
6644 }
6645
6646 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
6647         if ((_res & 1) != 0) return;
6648         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
6649         FREE((void*)_res);
6650         C2Tuple_OutPointScriptZ_free(_res_conv);
6651 }
6652
6653 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
6654         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
6655         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6656         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
6657         return (long)ret_ref;
6658 }
6659
6660 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
6661         LDKCVec_u8Z b_ref;
6662         b_ref.datalen = *((uint32_t*)b);
6663         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
6664         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
6665         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6666         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
6667         return (long)ret_ref;
6668 }
6669
6670 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
6671         if ((_res & 1) != 0) return;
6672         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
6673         FREE((void*)_res);
6674         C2Tuple_u32ScriptZ_free(_res_conv);
6675 }
6676
6677 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
6678         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
6679         _res_constr.datalen = *((uint32_t*)_res);
6680         if (_res_constr.datalen > 0)
6681                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6682         else
6683                 _res_constr.data = NULL;
6684         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6685         for (size_t e = 0; e < _res_constr.datalen; e++) {
6686                 uint32_t _res_conv_30 = _res_vals[e];
6687                 LDKC2Tuple_u32ScriptZ _res_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_30) & ~1);
6688                 FREE((void*)_res_conv_30);
6689                 _res_constr.data[e] = _res_conv_30_conv;
6690         }
6691         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
6692 }
6693
6694 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
6695         LDKThirtyTwoBytes a_ref;
6696         CHECK(*((uint32_t*)a) == 32);
6697         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6698         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
6699         b_constr.datalen = *((uint32_t*)b);
6700         if (b_constr.datalen > 0)
6701                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
6702         else
6703                 b_constr.data = NULL;
6704         uint32_t* b_vals = (uint32_t*)(b + 4);
6705         for (size_t e = 0; e < b_constr.datalen; e++) {
6706                 uint32_t b_conv_30 = b_vals[e];
6707                 LDKC2Tuple_u32ScriptZ b_conv_30_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_30) & ~1);
6708                 FREE((void*)b_conv_30);
6709                 b_constr.data[e] = b_conv_30_conv;
6710         }
6711         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
6712         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
6713         return (long)ret_ref;
6714 }
6715
6716 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
6717         if ((_res & 1) != 0) return;
6718         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
6719         FREE((void*)_res);
6720         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
6721 }
6722
6723 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
6724         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
6725         _res_constr.datalen = *((uint32_t*)_res);
6726         if (_res_constr.datalen > 0)
6727                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
6728         else
6729                 _res_constr.data = NULL;
6730         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6731         for (size_t c = 0; c < _res_constr.datalen; c++) {
6732                 uint32_t _res_conv_54 = _res_vals[c];
6733                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_54_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_54) & ~1);
6734                 FREE((void*)_res_conv_54);
6735                 _res_constr.data[c] = _res_conv_54_conv;
6736         }
6737         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
6738 }
6739
6740 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
6741         LDKCVec_TransactionZ _res_constr;
6742         _res_constr.datalen = *((uint32_t*)_res);
6743         if (_res_constr.datalen > 0)
6744                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6745         else
6746                 _res_constr.data = NULL;
6747         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
6748         for (size_t m = 0; m < _res_constr.datalen; m++) {
6749                 int8_tArray _res_conv_12 = _res_vals[m];
6750                 LDKTransaction _res_conv_12_ref;
6751                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
6752                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
6753                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
6754                 _res_conv_12_ref.data_is_owned = true;
6755                 _res_constr.data[m] = _res_conv_12_ref;
6756         }
6757         CVec_TransactionZ_free(_res_constr);
6758 }
6759
6760 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
6761         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
6762         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6763         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
6764         return (long)ret_ref;
6765 }
6766
6767 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
6768         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
6769         FREE((void*)b);
6770         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6771         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
6772         return (long)ret_ref;
6773 }
6774
6775 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
6776         if ((_res & 1) != 0) return;
6777         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
6778         FREE((void*)_res);
6779         C2Tuple_u32TxOutZ_free(_res_conv);
6780 }
6781
6782 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
6783         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
6784         _res_constr.datalen = *((uint32_t*)_res);
6785         if (_res_constr.datalen > 0)
6786                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6787         else
6788                 _res_constr.data = NULL;
6789         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6790         for (size_t z = 0; z < _res_constr.datalen; z++) {
6791                 uint32_t _res_conv_25 = _res_vals[z];
6792                 LDKC2Tuple_u32TxOutZ _res_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_25) & ~1);
6793                 FREE((void*)_res_conv_25);
6794                 _res_constr.data[z] = _res_conv_25_conv;
6795         }
6796         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
6797 }
6798
6799 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
6800         LDKThirtyTwoBytes a_ref;
6801         CHECK(*((uint32_t*)a) == 32);
6802         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6803         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
6804         b_constr.datalen = *((uint32_t*)b);
6805         if (b_constr.datalen > 0)
6806                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
6807         else
6808                 b_constr.data = NULL;
6809         uint32_t* b_vals = (uint32_t*)(b + 4);
6810         for (size_t z = 0; z < b_constr.datalen; z++) {
6811                 uint32_t b_conv_25 = b_vals[z];
6812                 LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
6813                 FREE((void*)b_conv_25);
6814                 b_constr.data[z] = b_conv_25_conv;
6815         }
6816         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
6817         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
6818         return (long)ret_ref;
6819 }
6820
6821 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
6822         if ((_res & 1) != 0) return;
6823         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
6824         FREE((void*)_res);
6825         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
6826 }
6827
6828 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
6829         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
6830         _res_constr.datalen = *((uint32_t*)_res);
6831         if (_res_constr.datalen > 0)
6832                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
6833         else
6834                 _res_constr.data = NULL;
6835         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6836         for (size_t x = 0; x < _res_constr.datalen; x++) {
6837                 uint32_t _res_conv_49 = _res_vals[x];
6838                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_49) & ~1);
6839                 FREE((void*)_res_conv_49);
6840                 _res_constr.data[x] = _res_conv_49_conv;
6841         }
6842         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
6843 }
6844
6845 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
6846         LDKThirtyTwoBytes a_ref;
6847         CHECK(*((uint32_t*)a) == 32);
6848         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
6849         LDKChannelMonitor b_conv;
6850         b_conv.inner = (void*)(b & (~1));
6851         b_conv.is_owned = (b & 1) || (b == 0);
6852         b_conv = ChannelMonitor_clone(&b_conv);
6853         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6854         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
6855         return (long)ret_ref;
6856 }
6857
6858 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
6859         if ((_res & 1) != 0) return;
6860         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
6861         FREE((void*)_res);
6862         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
6863 }
6864
6865 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
6866         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
6867         FREE((void*)o);
6868         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6869         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
6870         return (long)ret_conv;
6871 }
6872
6873 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
6874         LDKDecodeError e_conv;
6875         e_conv.inner = (void*)(e & (~1));
6876         e_conv.is_owned = (e & 1) || (e == 0);
6877         e_conv = DecodeError_clone(&e_conv);
6878         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6879         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
6880         return (long)ret_conv;
6881 }
6882
6883 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
6884         if ((_res & 1) != 0) return;
6885         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
6886         FREE((void*)_res);
6887         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
6888 }
6889
6890 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
6891         LDKCVec_SpendableOutputDescriptorZ _res_constr;
6892         _res_constr.datalen = *((uint32_t*)_res);
6893         if (_res_constr.datalen > 0)
6894                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
6895         else
6896                 _res_constr.data = NULL;
6897         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6898         for (size_t b = 0; b < _res_constr.datalen; b++) {
6899                 uint32_t _res_conv_27 = _res_vals[b];
6900                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
6901                 FREE((void*)_res_conv_27);
6902                 _res_constr.data[b] = _res_conv_27_conv;
6903         }
6904         CVec_SpendableOutputDescriptorZ_free(_res_constr);
6905 }
6906
6907 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
6908         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
6909         FREE((void*)o);
6910         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6911         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
6912         return (long)ret_conv;
6913 }
6914
6915 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
6916         LDKAccessError e_conv = LDKAccessError_from_js(e);
6917         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6918         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
6919         return (long)ret_conv;
6920 }
6921
6922 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
6923         if ((_res & 1) != 0) return;
6924         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
6925         FREE((void*)_res);
6926         CResult_TxOutAccessErrorZ_free(_res_conv);
6927 }
6928
6929 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
6930         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
6931         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6932         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
6933         return (long)ret_conv;
6934 }
6935
6936 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
6937         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6938         *ret_conv = CResult_NoneAPIErrorZ_ok();
6939         return (long)ret_conv;
6940 }
6941
6942 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
6943         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
6944         FREE((void*)e);
6945         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6946         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
6947         return (long)ret_conv;
6948 }
6949
6950 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
6951         if ((_res & 1) != 0) return;
6952         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
6953         FREE((void*)_res);
6954         CResult_NoneAPIErrorZ_free(_res_conv);
6955 }
6956
6957 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
6958         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
6959         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6960         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
6961         return (long)ret_conv;
6962 }
6963
6964 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
6965         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
6966         _res_constr.datalen = *((uint32_t*)_res);
6967         if (_res_constr.datalen > 0)
6968                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
6969         else
6970                 _res_constr.data = NULL;
6971         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6972         for (size_t w = 0; w < _res_constr.datalen; w++) {
6973                 uint32_t _res_conv_22 = _res_vals[w];
6974                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
6975                 FREE((void*)_res_conv_22);
6976                 _res_constr.data[w] = _res_conv_22_conv;
6977         }
6978         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
6979 }
6980
6981 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
6982         LDKCVec_APIErrorZ _res_constr;
6983         _res_constr.datalen = *((uint32_t*)_res);
6984         if (_res_constr.datalen > 0)
6985                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
6986         else
6987                 _res_constr.data = NULL;
6988         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6989         for (size_t k = 0; k < _res_constr.datalen; k++) {
6990                 uint32_t _res_conv_10 = _res_vals[k];
6991                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
6992                 FREE((void*)_res_conv_10);
6993                 _res_constr.data[k] = _res_conv_10_conv;
6994         }
6995         CVec_APIErrorZ_free(_res_constr);
6996 }
6997
6998 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
6999         LDKCVec_ChannelDetailsZ _res_constr;
7000         _res_constr.datalen = *((uint32_t*)_res);
7001         if (_res_constr.datalen > 0)
7002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7003         else
7004                 _res_constr.data = NULL;
7005         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7006         for (size_t q = 0; q < _res_constr.datalen; q++) {
7007                 uint32_t _res_conv_16 = _res_vals[q];
7008                 LDKChannelDetails _res_conv_16_conv;
7009                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7010                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7011                 _res_constr.data[q] = _res_conv_16_conv;
7012         }
7013         CVec_ChannelDetailsZ_free(_res_constr);
7014 }
7015
7016 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
7017         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7018         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
7019         return (long)ret_conv;
7020 }
7021
7022 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
7023         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
7024         FREE((void*)e);
7025         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7026         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
7027         return (long)ret_conv;
7028 }
7029
7030 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
7031         if ((_res & 1) != 0) return;
7032         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
7033         FREE((void*)_res);
7034         CResult_NonePaymentSendFailureZ_free(_res_conv);
7035 }
7036
7037 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
7038         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
7039         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7040         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
7041         return (long)ret_conv;
7042 }
7043
7044 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
7045         LDKCVec_ChannelMonitorZ _res_constr;
7046         _res_constr.datalen = *((uint32_t*)_res);
7047         if (_res_constr.datalen > 0)
7048                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7049         else
7050                 _res_constr.data = NULL;
7051         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7052         for (size_t q = 0; q < _res_constr.datalen; q++) {
7053                 uint32_t _res_conv_16 = _res_vals[q];
7054                 LDKChannelMonitor _res_conv_16_conv;
7055                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7056                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7057                 _res_constr.data[q] = _res_conv_16_conv;
7058         }
7059         CVec_ChannelMonitorZ_free(_res_constr);
7060 }
7061
7062 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
7063         LDKThirtyTwoBytes a_ref;
7064         CHECK(*((uint32_t*)a) == 32);
7065         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
7066         LDKChannelManager b_conv;
7067         b_conv.inner = (void*)(b & (~1));
7068         b_conv.is_owned = (b & 1) || (b == 0);
7069         // Warning: we need a move here but no clone is available for LDKChannelManager
7070         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
7071         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
7072         return (long)ret_ref;
7073 }
7074
7075 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
7076         if ((_res & 1) != 0) return;
7077         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
7078         FREE((void*)_res);
7079         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
7080 }
7081
7082 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
7083         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
7084         FREE((void*)o);
7085         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7086         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
7087         return (long)ret_conv;
7088 }
7089
7090 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
7091         LDKDecodeError e_conv;
7092         e_conv.inner = (void*)(e & (~1));
7093         e_conv.is_owned = (e & 1) || (e == 0);
7094         e_conv = DecodeError_clone(&e_conv);
7095         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7096         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
7097         return (long)ret_conv;
7098 }
7099
7100 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
7101         if ((_res & 1) != 0) return;
7102         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7103         FREE((void*)_res);
7104         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
7105 }
7106
7107 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
7108         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
7109         FREE((void*)o);
7110         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7111         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
7112         return (long)ret_conv;
7113 }
7114
7115 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
7116         LDKDecodeError e_conv;
7117         e_conv.inner = (void*)(e & (~1));
7118         e_conv.is_owned = (e & 1) || (e == 0);
7119         e_conv = DecodeError_clone(&e_conv);
7120         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7121         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
7122         return (long)ret_conv;
7123 }
7124
7125 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
7126         if ((_res & 1) != 0) return;
7127         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
7128         FREE((void*)_res);
7129         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
7130 }
7131
7132 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
7133         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
7134         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7135         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
7136         return (long)ret_conv;
7137 }
7138
7139 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
7140         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
7141         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7142         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
7143         return (long)ret_ref;
7144 }
7145
7146 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
7147         LDKSignature a_ref;
7148         CHECK(*((uint32_t*)a) == 64);
7149         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
7150         LDKCVec_SignatureZ b_constr;
7151         b_constr.datalen = *((uint32_t*)b);
7152         if (b_constr.datalen > 0)
7153                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7154         else
7155                 b_constr.data = NULL;
7156         int8_tArray* b_vals = (int8_tArray*)(b + 4);
7157         for (size_t m = 0; m < b_constr.datalen; m++) {
7158                 int8_tArray b_conv_12 = b_vals[m];
7159                 LDKSignature b_conv_12_ref;
7160                 CHECK(*((uint32_t*)b_conv_12) == 64);
7161                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
7162                 b_constr.data[m] = b_conv_12_ref;
7163         }
7164         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
7165         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
7166         return (long)ret_ref;
7167 }
7168
7169 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
7170         if ((_res & 1) != 0) return;
7171         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
7172         FREE((void*)_res);
7173         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
7174 }
7175
7176 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
7177         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
7178         FREE((void*)o);
7179         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7180         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
7181         return (long)ret_conv;
7182 }
7183
7184 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
7185         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7186         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
7187         return (long)ret_conv;
7188 }
7189
7190 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
7191         if ((_res & 1) != 0) return;
7192         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
7193         FREE((void*)_res);
7194         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
7195 }
7196
7197 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
7198         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
7199         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
7200         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
7201         return (long)ret_conv;
7202 }
7203
7204 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
7205         LDKSignature o_ref;
7206         CHECK(*((uint32_t*)o) == 64);
7207         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
7208         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7209         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
7210         return (long)ret_conv;
7211 }
7212
7213 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
7214         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7215         *ret_conv = CResult_SignatureNoneZ_err();
7216         return (long)ret_conv;
7217 }
7218
7219 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
7220         if ((_res & 1) != 0) return;
7221         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
7222         FREE((void*)_res);
7223         CResult_SignatureNoneZ_free(_res_conv);
7224 }
7225
7226 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
7227         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
7228         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
7229         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
7230         return (long)ret_conv;
7231 }
7232
7233 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
7234         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
7235         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7236         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
7237         return (long)ret_conv;
7238 }
7239
7240 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
7241         LDKDecodeError e_conv;
7242         e_conv.inner = (void*)(e & (~1));
7243         e_conv.is_owned = (e & 1) || (e == 0);
7244         e_conv = DecodeError_clone(&e_conv);
7245         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7246         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
7247         return (long)ret_conv;
7248 }
7249
7250 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
7251         if ((_res & 1) != 0) return;
7252         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
7253         FREE((void*)_res);
7254         CResult_SignDecodeErrorZ_free(_res_conv);
7255 }
7256
7257 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
7258         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
7259         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7260         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
7261         return (long)ret_conv;
7262 }
7263
7264 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
7265         LDKCVec_CVec_u8ZZ _res_constr;
7266         _res_constr.datalen = *((uint32_t*)_res);
7267         if (_res_constr.datalen > 0)
7268                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7269         else
7270                 _res_constr.data = NULL;
7271         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7272         for (size_t m = 0; m < _res_constr.datalen; m++) {
7273                 int8_tArray _res_conv_12 = _res_vals[m];
7274                 LDKCVec_u8Z _res_conv_12_ref;
7275                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
7276                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7277                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
7278                 _res_constr.data[m] = _res_conv_12_ref;
7279         }
7280         CVec_CVec_u8ZZ_free(_res_constr);
7281 }
7282
7283 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
7284         LDKCVec_CVec_u8ZZ o_constr;
7285         o_constr.datalen = *((uint32_t*)o);
7286         if (o_constr.datalen > 0)
7287                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
7288         else
7289                 o_constr.data = NULL;
7290         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7291         for (size_t m = 0; m < o_constr.datalen; m++) {
7292                 int8_tArray o_conv_12 = o_vals[m];
7293                 LDKCVec_u8Z o_conv_12_ref;
7294                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
7295                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
7296                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
7297                 o_constr.data[m] = o_conv_12_ref;
7298         }
7299         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7300         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
7301         return (long)ret_conv;
7302 }
7303
7304 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
7305         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7306         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
7307         return (long)ret_conv;
7308 }
7309
7310 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
7311         if ((_res & 1) != 0) return;
7312         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
7313         FREE((void*)_res);
7314         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
7315 }
7316
7317 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
7318         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
7319         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
7320         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
7321         return (long)ret_conv;
7322 }
7323
7324 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
7325         LDKInMemorySigner o_conv;
7326         o_conv.inner = (void*)(o & (~1));
7327         o_conv.is_owned = (o & 1) || (o == 0);
7328         o_conv = InMemorySigner_clone(&o_conv);
7329         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7330         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
7331         return (long)ret_conv;
7332 }
7333
7334 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
7335         LDKDecodeError e_conv;
7336         e_conv.inner = (void*)(e & (~1));
7337         e_conv.is_owned = (e & 1) || (e == 0);
7338         e_conv = DecodeError_clone(&e_conv);
7339         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7340         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
7341         return (long)ret_conv;
7342 }
7343
7344 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
7345         if ((_res & 1) != 0) return;
7346         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
7347         FREE((void*)_res);
7348         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
7349 }
7350
7351 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
7352         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
7353         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
7354         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
7355         return (long)ret_conv;
7356 }
7357
7358 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
7359         LDKCVec_TxOutZ _res_constr;
7360         _res_constr.datalen = *((uint32_t*)_res);
7361         if (_res_constr.datalen > 0)
7362                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
7363         else
7364                 _res_constr.data = NULL;
7365         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7366         for (size_t h = 0; h < _res_constr.datalen; h++) {
7367                 uint32_t _res_conv_7 = _res_vals[h];
7368                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
7369                 FREE((void*)_res_conv_7);
7370                 _res_constr.data[h] = _res_conv_7_conv;
7371         }
7372         CVec_TxOutZ_free(_res_constr);
7373 }
7374
7375 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
7376         LDKTransaction o_ref;
7377         o_ref.datalen = *((uint32_t*)o);
7378         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
7379         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
7380         o_ref.data_is_owned = true;
7381         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7382         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
7383         return (long)ret_conv;
7384 }
7385
7386 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
7387         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
7388         *ret_conv = CResult_TransactionNoneZ_err();
7389         return (long)ret_conv;
7390 }
7391
7392 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
7393         if ((_res & 1) != 0) return;
7394         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
7395         FREE((void*)_res);
7396         CResult_TransactionNoneZ_free(_res_conv);
7397 }
7398
7399 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7400         LDKCVec_RouteHopZ _res_constr;
7401         _res_constr.datalen = *((uint32_t*)_res);
7402         if (_res_constr.datalen > 0)
7403                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7404         else
7405                 _res_constr.data = NULL;
7406         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7407         for (size_t k = 0; k < _res_constr.datalen; k++) {
7408                 uint32_t _res_conv_10 = _res_vals[k];
7409                 LDKRouteHop _res_conv_10_conv;
7410                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7411                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7412                 _res_constr.data[k] = _res_conv_10_conv;
7413         }
7414         CVec_RouteHopZ_free(_res_constr);
7415 }
7416
7417 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7418         LDKCVec_CVec_RouteHopZZ _res_constr;
7419         _res_constr.datalen = *((uint32_t*)_res);
7420         if (_res_constr.datalen > 0)
7421                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7422         else
7423                 _res_constr.data = NULL;
7424         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7425         for (size_t m = 0; m < _res_constr.datalen; m++) {
7426                 uint32_tArray _res_conv_12 = _res_vals[m];
7427                 LDKCVec_RouteHopZ _res_conv_12_constr;
7428                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7429                 if (_res_conv_12_constr.datalen > 0)
7430                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7431                 else
7432                         _res_conv_12_constr.data = NULL;
7433                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7434                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7435                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7436                         LDKRouteHop _res_conv_12_conv_10_conv;
7437                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7438                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7439                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7440                 }
7441                 _res_constr.data[m] = _res_conv_12_constr;
7442         }
7443         CVec_CVec_RouteHopZZ_free(_res_constr);
7444 }
7445
7446 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7447         LDKRoute o_conv;
7448         o_conv.inner = (void*)(o & (~1));
7449         o_conv.is_owned = (o & 1) || (o == 0);
7450         o_conv = Route_clone(&o_conv);
7451         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7452         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7453         return (long)ret_conv;
7454 }
7455
7456 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7457         LDKDecodeError e_conv;
7458         e_conv.inner = (void*)(e & (~1));
7459         e_conv.is_owned = (e & 1) || (e == 0);
7460         e_conv = DecodeError_clone(&e_conv);
7461         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7462         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7463         return (long)ret_conv;
7464 }
7465
7466 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7467         if ((_res & 1) != 0) return;
7468         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7469         FREE((void*)_res);
7470         CResult_RouteDecodeErrorZ_free(_res_conv);
7471 }
7472
7473 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7474         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7475         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7476         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7477         return (long)ret_conv;
7478 }
7479
7480 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7481         LDKCVec_RouteHintZ _res_constr;
7482         _res_constr.datalen = *((uint32_t*)_res);
7483         if (_res_constr.datalen > 0)
7484                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7485         else
7486                 _res_constr.data = NULL;
7487         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7488         for (size_t l = 0; l < _res_constr.datalen; l++) {
7489                 uint32_t _res_conv_11 = _res_vals[l];
7490                 LDKRouteHint _res_conv_11_conv;
7491                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
7492                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
7493                 _res_constr.data[l] = _res_conv_11_conv;
7494         }
7495         CVec_RouteHintZ_free(_res_constr);
7496 }
7497
7498 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
7499         LDKRoute o_conv;
7500         o_conv.inner = (void*)(o & (~1));
7501         o_conv.is_owned = (o & 1) || (o == 0);
7502         o_conv = Route_clone(&o_conv);
7503         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7504         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
7505         return (long)ret_conv;
7506 }
7507
7508 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
7509         LDKLightningError e_conv;
7510         e_conv.inner = (void*)(e & (~1));
7511         e_conv.is_owned = (e & 1) || (e == 0);
7512         e_conv = LightningError_clone(&e_conv);
7513         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7514         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
7515         return (long)ret_conv;
7516 }
7517
7518 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
7519         if ((_res & 1) != 0) return;
7520         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
7521         FREE((void*)_res);
7522         CResult_RouteLightningErrorZ_free(_res_conv);
7523 }
7524
7525 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
7526         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
7527         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7528         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
7529         return (long)ret_conv;
7530 }
7531
7532 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
7533         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
7534         FREE((void*)o);
7535         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7536         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
7537         return (long)ret_conv;
7538 }
7539
7540 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
7541         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7542         *ret_conv = CResult_NetAddressu8Z_err(e);
7543         return (long)ret_conv;
7544 }
7545
7546 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
7547         if ((_res & 1) != 0) return;
7548         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
7549         FREE((void*)_res);
7550         CResult_NetAddressu8Z_free(_res_conv);
7551 }
7552
7553 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
7554         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
7555         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
7556         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
7557         return (long)ret_conv;
7558 }
7559
7560 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
7561         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
7562         FREE((void*)o);
7563         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7564         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
7565         return (long)ret_conv;
7566 }
7567
7568 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
7569         LDKDecodeError e_conv;
7570         e_conv.inner = (void*)(e & (~1));
7571         e_conv.is_owned = (e & 1) || (e == 0);
7572         e_conv = DecodeError_clone(&e_conv);
7573         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7574         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
7575         return (long)ret_conv;
7576 }
7577
7578 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
7579         if ((_res & 1) != 0) return;
7580         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
7581         FREE((void*)_res);
7582         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
7583 }
7584
7585 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
7586         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
7587         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
7588         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
7589         return (long)ret_conv;
7590 }
7591
7592 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
7593         LDKCVec_UpdateAddHTLCZ _res_constr;
7594         _res_constr.datalen = *((uint32_t*)_res);
7595         if (_res_constr.datalen > 0)
7596                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
7597         else
7598                 _res_constr.data = NULL;
7599         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7600         for (size_t p = 0; p < _res_constr.datalen; p++) {
7601                 uint32_t _res_conv_15 = _res_vals[p];
7602                 LDKUpdateAddHTLC _res_conv_15_conv;
7603                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
7604                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
7605                 _res_constr.data[p] = _res_conv_15_conv;
7606         }
7607         CVec_UpdateAddHTLCZ_free(_res_constr);
7608 }
7609
7610 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
7611         LDKCVec_UpdateFulfillHTLCZ _res_constr;
7612         _res_constr.datalen = *((uint32_t*)_res);
7613         if (_res_constr.datalen > 0)
7614                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
7615         else
7616                 _res_constr.data = NULL;
7617         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7618         for (size_t t = 0; t < _res_constr.datalen; t++) {
7619                 uint32_t _res_conv_19 = _res_vals[t];
7620                 LDKUpdateFulfillHTLC _res_conv_19_conv;
7621                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
7622                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
7623                 _res_constr.data[t] = _res_conv_19_conv;
7624         }
7625         CVec_UpdateFulfillHTLCZ_free(_res_constr);
7626 }
7627
7628 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
7629         LDKCVec_UpdateFailHTLCZ _res_constr;
7630         _res_constr.datalen = *((uint32_t*)_res);
7631         if (_res_constr.datalen > 0)
7632                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
7633         else
7634                 _res_constr.data = NULL;
7635         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7636         for (size_t q = 0; q < _res_constr.datalen; q++) {
7637                 uint32_t _res_conv_16 = _res_vals[q];
7638                 LDKUpdateFailHTLC _res_conv_16_conv;
7639                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7640                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7641                 _res_constr.data[q] = _res_conv_16_conv;
7642         }
7643         CVec_UpdateFailHTLCZ_free(_res_constr);
7644 }
7645
7646 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
7647         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
7648         _res_constr.datalen = *((uint32_t*)_res);
7649         if (_res_constr.datalen > 0)
7650                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
7651         else
7652                 _res_constr.data = NULL;
7653         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7654         for (size_t z = 0; z < _res_constr.datalen; z++) {
7655                 uint32_t _res_conv_25 = _res_vals[z];
7656                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
7657                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
7658                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
7659                 _res_constr.data[z] = _res_conv_25_conv;
7660         }
7661         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
7662 }
7663
7664 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
7665         LDKAcceptChannel o_conv;
7666         o_conv.inner = (void*)(o & (~1));
7667         o_conv.is_owned = (o & 1) || (o == 0);
7668         o_conv = AcceptChannel_clone(&o_conv);
7669         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7670         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
7671         return (long)ret_conv;
7672 }
7673
7674 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
7675         LDKDecodeError e_conv;
7676         e_conv.inner = (void*)(e & (~1));
7677         e_conv.is_owned = (e & 1) || (e == 0);
7678         e_conv = DecodeError_clone(&e_conv);
7679         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7680         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
7681         return (long)ret_conv;
7682 }
7683
7684 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
7685         if ((_res & 1) != 0) return;
7686         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7687         FREE((void*)_res);
7688         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
7689 }
7690
7691 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
7692         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
7693         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
7694         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
7695         return (long)ret_conv;
7696 }
7697
7698 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
7699         LDKAnnouncementSignatures o_conv;
7700         o_conv.inner = (void*)(o & (~1));
7701         o_conv.is_owned = (o & 1) || (o == 0);
7702         o_conv = AnnouncementSignatures_clone(&o_conv);
7703         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7704         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
7705         return (long)ret_conv;
7706 }
7707
7708 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
7709         LDKDecodeError e_conv;
7710         e_conv.inner = (void*)(e & (~1));
7711         e_conv.is_owned = (e & 1) || (e == 0);
7712         e_conv = DecodeError_clone(&e_conv);
7713         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7714         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
7715         return (long)ret_conv;
7716 }
7717
7718 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
7719         if ((_res & 1) != 0) return;
7720         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
7721         FREE((void*)_res);
7722         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
7723 }
7724
7725 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
7726         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
7727         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
7728         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
7729         return (long)ret_conv;
7730 }
7731
7732 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
7733         LDKChannelReestablish o_conv;
7734         o_conv.inner = (void*)(o & (~1));
7735         o_conv.is_owned = (o & 1) || (o == 0);
7736         o_conv = ChannelReestablish_clone(&o_conv);
7737         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7738         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
7739         return (long)ret_conv;
7740 }
7741
7742 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
7743         LDKDecodeError e_conv;
7744         e_conv.inner = (void*)(e & (~1));
7745         e_conv.is_owned = (e & 1) || (e == 0);
7746         e_conv = DecodeError_clone(&e_conv);
7747         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7748         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
7749         return (long)ret_conv;
7750 }
7751
7752 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
7753         if ((_res & 1) != 0) return;
7754         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
7755         FREE((void*)_res);
7756         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
7757 }
7758
7759 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
7760         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
7761         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
7762         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
7763         return (long)ret_conv;
7764 }
7765
7766 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
7767         LDKClosingSigned o_conv;
7768         o_conv.inner = (void*)(o & (~1));
7769         o_conv.is_owned = (o & 1) || (o == 0);
7770         o_conv = ClosingSigned_clone(&o_conv);
7771         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7772         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
7773         return (long)ret_conv;
7774 }
7775
7776 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
7777         LDKDecodeError e_conv;
7778         e_conv.inner = (void*)(e & (~1));
7779         e_conv.is_owned = (e & 1) || (e == 0);
7780         e_conv = DecodeError_clone(&e_conv);
7781         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7782         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
7783         return (long)ret_conv;
7784 }
7785
7786 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
7787         if ((_res & 1) != 0) return;
7788         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7789         FREE((void*)_res);
7790         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
7791 }
7792
7793 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
7794         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
7795         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
7796         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
7797         return (long)ret_conv;
7798 }
7799
7800 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
7801         LDKCommitmentSigned o_conv;
7802         o_conv.inner = (void*)(o & (~1));
7803         o_conv.is_owned = (o & 1) || (o == 0);
7804         o_conv = CommitmentSigned_clone(&o_conv);
7805         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7806         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
7807         return (long)ret_conv;
7808 }
7809
7810 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
7811         LDKDecodeError e_conv;
7812         e_conv.inner = (void*)(e & (~1));
7813         e_conv.is_owned = (e & 1) || (e == 0);
7814         e_conv = DecodeError_clone(&e_conv);
7815         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7816         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
7817         return (long)ret_conv;
7818 }
7819
7820 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
7821         if ((_res & 1) != 0) return;
7822         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7823         FREE((void*)_res);
7824         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
7825 }
7826
7827 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
7828         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
7829         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
7830         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
7831         return (long)ret_conv;
7832 }
7833
7834 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
7835         LDKFundingCreated o_conv;
7836         o_conv.inner = (void*)(o & (~1));
7837         o_conv.is_owned = (o & 1) || (o == 0);
7838         o_conv = FundingCreated_clone(&o_conv);
7839         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7840         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
7841         return (long)ret_conv;
7842 }
7843
7844 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
7845         LDKDecodeError e_conv;
7846         e_conv.inner = (void*)(e & (~1));
7847         e_conv.is_owned = (e & 1) || (e == 0);
7848         e_conv = DecodeError_clone(&e_conv);
7849         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7850         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
7851         return (long)ret_conv;
7852 }
7853
7854 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
7855         if ((_res & 1) != 0) return;
7856         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7857         FREE((void*)_res);
7858         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
7859 }
7860
7861 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
7862         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
7863         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
7864         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
7865         return (long)ret_conv;
7866 }
7867
7868 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
7869         LDKFundingSigned o_conv;
7870         o_conv.inner = (void*)(o & (~1));
7871         o_conv.is_owned = (o & 1) || (o == 0);
7872         o_conv = FundingSigned_clone(&o_conv);
7873         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7874         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
7875         return (long)ret_conv;
7876 }
7877
7878 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
7879         LDKDecodeError e_conv;
7880         e_conv.inner = (void*)(e & (~1));
7881         e_conv.is_owned = (e & 1) || (e == 0);
7882         e_conv = DecodeError_clone(&e_conv);
7883         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7884         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
7885         return (long)ret_conv;
7886 }
7887
7888 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
7889         if ((_res & 1) != 0) return;
7890         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7891         FREE((void*)_res);
7892         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
7893 }
7894
7895 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
7896         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
7897         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
7898         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
7899         return (long)ret_conv;
7900 }
7901
7902 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
7903         LDKFundingLocked o_conv;
7904         o_conv.inner = (void*)(o & (~1));
7905         o_conv.is_owned = (o & 1) || (o == 0);
7906         o_conv = FundingLocked_clone(&o_conv);
7907         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7908         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
7909         return (long)ret_conv;
7910 }
7911
7912 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
7913         LDKDecodeError e_conv;
7914         e_conv.inner = (void*)(e & (~1));
7915         e_conv.is_owned = (e & 1) || (e == 0);
7916         e_conv = DecodeError_clone(&e_conv);
7917         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7918         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
7919         return (long)ret_conv;
7920 }
7921
7922 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
7923         if ((_res & 1) != 0) return;
7924         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
7925         FREE((void*)_res);
7926         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
7927 }
7928
7929 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
7930         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
7931         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
7932         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
7933         return (long)ret_conv;
7934 }
7935
7936 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
7937         LDKInit o_conv;
7938         o_conv.inner = (void*)(o & (~1));
7939         o_conv.is_owned = (o & 1) || (o == 0);
7940         o_conv = Init_clone(&o_conv);
7941         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7942         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
7943         return (long)ret_conv;
7944 }
7945
7946 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
7947         LDKDecodeError e_conv;
7948         e_conv.inner = (void*)(e & (~1));
7949         e_conv.is_owned = (e & 1) || (e == 0);
7950         e_conv = DecodeError_clone(&e_conv);
7951         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7952         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
7953         return (long)ret_conv;
7954 }
7955
7956 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
7957         if ((_res & 1) != 0) return;
7958         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
7959         FREE((void*)_res);
7960         CResult_InitDecodeErrorZ_free(_res_conv);
7961 }
7962
7963 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
7964         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
7965         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
7966         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
7967         return (long)ret_conv;
7968 }
7969
7970 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
7971         LDKOpenChannel o_conv;
7972         o_conv.inner = (void*)(o & (~1));
7973         o_conv.is_owned = (o & 1) || (o == 0);
7974         o_conv = OpenChannel_clone(&o_conv);
7975         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7976         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
7977         return (long)ret_conv;
7978 }
7979
7980 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
7981         LDKDecodeError e_conv;
7982         e_conv.inner = (void*)(e & (~1));
7983         e_conv.is_owned = (e & 1) || (e == 0);
7984         e_conv = DecodeError_clone(&e_conv);
7985         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
7986         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
7987         return (long)ret_conv;
7988 }
7989
7990 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
7991         if ((_res & 1) != 0) return;
7992         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
7993         FREE((void*)_res);
7994         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
7995 }
7996
7997 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
7998         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
7999         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
8000         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
8001         return (long)ret_conv;
8002 }
8003
8004 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
8005         LDKRevokeAndACK o_conv;
8006         o_conv.inner = (void*)(o & (~1));
8007         o_conv.is_owned = (o & 1) || (o == 0);
8008         o_conv = RevokeAndACK_clone(&o_conv);
8009         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8010         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
8011         return (long)ret_conv;
8012 }
8013
8014 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
8015         LDKDecodeError e_conv;
8016         e_conv.inner = (void*)(e & (~1));
8017         e_conv.is_owned = (e & 1) || (e == 0);
8018         e_conv = DecodeError_clone(&e_conv);
8019         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8020         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
8021         return (long)ret_conv;
8022 }
8023
8024 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
8025         if ((_res & 1) != 0) return;
8026         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
8027         FREE((void*)_res);
8028         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
8029 }
8030
8031 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
8032         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
8033         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
8034         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
8035         return (long)ret_conv;
8036 }
8037
8038 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
8039         LDKShutdown o_conv;
8040         o_conv.inner = (void*)(o & (~1));
8041         o_conv.is_owned = (o & 1) || (o == 0);
8042         o_conv = Shutdown_clone(&o_conv);
8043         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8044         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
8045         return (long)ret_conv;
8046 }
8047
8048 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
8049         LDKDecodeError e_conv;
8050         e_conv.inner = (void*)(e & (~1));
8051         e_conv.is_owned = (e & 1) || (e == 0);
8052         e_conv = DecodeError_clone(&e_conv);
8053         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8054         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
8055         return (long)ret_conv;
8056 }
8057
8058 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
8059         if ((_res & 1) != 0) return;
8060         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
8061         FREE((void*)_res);
8062         CResult_ShutdownDecodeErrorZ_free(_res_conv);
8063 }
8064
8065 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
8066         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
8067         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
8068         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
8069         return (long)ret_conv;
8070 }
8071
8072 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
8073         LDKUpdateFailHTLC o_conv;
8074         o_conv.inner = (void*)(o & (~1));
8075         o_conv.is_owned = (o & 1) || (o == 0);
8076         o_conv = UpdateFailHTLC_clone(&o_conv);
8077         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8078         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
8079         return (long)ret_conv;
8080 }
8081
8082 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
8083         LDKDecodeError e_conv;
8084         e_conv.inner = (void*)(e & (~1));
8085         e_conv.is_owned = (e & 1) || (e == 0);
8086         e_conv = DecodeError_clone(&e_conv);
8087         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8088         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
8089         return (long)ret_conv;
8090 }
8091
8092 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
8093         if ((_res & 1) != 0) return;
8094         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8095         FREE((void*)_res);
8096         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
8097 }
8098
8099 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
8100         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
8101         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
8102         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
8103         return (long)ret_conv;
8104 }
8105
8106 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
8107         LDKUpdateFailMalformedHTLC o_conv;
8108         o_conv.inner = (void*)(o & (~1));
8109         o_conv.is_owned = (o & 1) || (o == 0);
8110         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
8111         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8112         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
8113         return (long)ret_conv;
8114 }
8115
8116 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
8117         LDKDecodeError e_conv;
8118         e_conv.inner = (void*)(e & (~1));
8119         e_conv.is_owned = (e & 1) || (e == 0);
8120         e_conv = DecodeError_clone(&e_conv);
8121         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8122         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
8123         return (long)ret_conv;
8124 }
8125
8126 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
8127         if ((_res & 1) != 0) return;
8128         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8129         FREE((void*)_res);
8130         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
8131 }
8132
8133 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
8134         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
8135         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
8136         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
8137         return (long)ret_conv;
8138 }
8139
8140 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
8141         LDKUpdateFee o_conv;
8142         o_conv.inner = (void*)(o & (~1));
8143         o_conv.is_owned = (o & 1) || (o == 0);
8144         o_conv = UpdateFee_clone(&o_conv);
8145         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8146         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
8147         return (long)ret_conv;
8148 }
8149
8150 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
8151         LDKDecodeError e_conv;
8152         e_conv.inner = (void*)(e & (~1));
8153         e_conv.is_owned = (e & 1) || (e == 0);
8154         e_conv = DecodeError_clone(&e_conv);
8155         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8156         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
8157         return (long)ret_conv;
8158 }
8159
8160 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
8161         if ((_res & 1) != 0) return;
8162         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8163         FREE((void*)_res);
8164         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
8165 }
8166
8167 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
8168         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
8169         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
8170         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
8171         return (long)ret_conv;
8172 }
8173
8174 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
8175         LDKUpdateFulfillHTLC o_conv;
8176         o_conv.inner = (void*)(o & (~1));
8177         o_conv.is_owned = (o & 1) || (o == 0);
8178         o_conv = UpdateFulfillHTLC_clone(&o_conv);
8179         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8180         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
8181         return (long)ret_conv;
8182 }
8183
8184 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
8185         LDKDecodeError e_conv;
8186         e_conv.inner = (void*)(e & (~1));
8187         e_conv.is_owned = (e & 1) || (e == 0);
8188         e_conv = DecodeError_clone(&e_conv);
8189         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8190         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
8191         return (long)ret_conv;
8192 }
8193
8194 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
8195         if ((_res & 1) != 0) return;
8196         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8197         FREE((void*)_res);
8198         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
8199 }
8200
8201 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
8202         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
8203         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
8204         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
8205         return (long)ret_conv;
8206 }
8207
8208 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
8209         LDKUpdateAddHTLC o_conv;
8210         o_conv.inner = (void*)(o & (~1));
8211         o_conv.is_owned = (o & 1) || (o == 0);
8212         o_conv = UpdateAddHTLC_clone(&o_conv);
8213         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8214         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
8215         return (long)ret_conv;
8216 }
8217
8218 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
8219         LDKDecodeError e_conv;
8220         e_conv.inner = (void*)(e & (~1));
8221         e_conv.is_owned = (e & 1) || (e == 0);
8222         e_conv = DecodeError_clone(&e_conv);
8223         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8224         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
8225         return (long)ret_conv;
8226 }
8227
8228 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
8229         if ((_res & 1) != 0) return;
8230         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
8231         FREE((void*)_res);
8232         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
8233 }
8234
8235 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
8236         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
8237         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
8238         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
8239         return (long)ret_conv;
8240 }
8241
8242 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
8243         LDKPing o_conv;
8244         o_conv.inner = (void*)(o & (~1));
8245         o_conv.is_owned = (o & 1) || (o == 0);
8246         o_conv = Ping_clone(&o_conv);
8247         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8248         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
8249         return (long)ret_conv;
8250 }
8251
8252 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
8253         LDKDecodeError e_conv;
8254         e_conv.inner = (void*)(e & (~1));
8255         e_conv.is_owned = (e & 1) || (e == 0);
8256         e_conv = DecodeError_clone(&e_conv);
8257         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8258         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
8259         return (long)ret_conv;
8260 }
8261
8262 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
8263         if ((_res & 1) != 0) return;
8264         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
8265         FREE((void*)_res);
8266         CResult_PingDecodeErrorZ_free(_res_conv);
8267 }
8268
8269 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
8270         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
8271         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
8272         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
8273         return (long)ret_conv;
8274 }
8275
8276 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
8277         LDKPong o_conv;
8278         o_conv.inner = (void*)(o & (~1));
8279         o_conv.is_owned = (o & 1) || (o == 0);
8280         o_conv = Pong_clone(&o_conv);
8281         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8282         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
8283         return (long)ret_conv;
8284 }
8285
8286 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
8287         LDKDecodeError e_conv;
8288         e_conv.inner = (void*)(e & (~1));
8289         e_conv.is_owned = (e & 1) || (e == 0);
8290         e_conv = DecodeError_clone(&e_conv);
8291         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8292         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
8293         return (long)ret_conv;
8294 }
8295
8296 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
8297         if ((_res & 1) != 0) return;
8298         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
8299         FREE((void*)_res);
8300         CResult_PongDecodeErrorZ_free(_res_conv);
8301 }
8302
8303 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
8304         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
8305         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
8306         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
8307         return (long)ret_conv;
8308 }
8309
8310 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8311         LDKUnsignedChannelAnnouncement o_conv;
8312         o_conv.inner = (void*)(o & (~1));
8313         o_conv.is_owned = (o & 1) || (o == 0);
8314         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
8315         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8316         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
8317         return (long)ret_conv;
8318 }
8319
8320 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8321         LDKDecodeError e_conv;
8322         e_conv.inner = (void*)(e & (~1));
8323         e_conv.is_owned = (e & 1) || (e == 0);
8324         e_conv = DecodeError_clone(&e_conv);
8325         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8326         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
8327         return (long)ret_conv;
8328 }
8329
8330 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8331         if ((_res & 1) != 0) return;
8332         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8333         FREE((void*)_res);
8334         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
8335 }
8336
8337 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8338         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8339         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
8340         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8341         return (long)ret_conv;
8342 }
8343
8344 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
8345         LDKChannelAnnouncement o_conv;
8346         o_conv.inner = (void*)(o & (~1));
8347         o_conv.is_owned = (o & 1) || (o == 0);
8348         o_conv = ChannelAnnouncement_clone(&o_conv);
8349         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8350         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
8351         return (long)ret_conv;
8352 }
8353
8354 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
8355         LDKDecodeError e_conv;
8356         e_conv.inner = (void*)(e & (~1));
8357         e_conv.is_owned = (e & 1) || (e == 0);
8358         e_conv = DecodeError_clone(&e_conv);
8359         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8360         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
8361         return (long)ret_conv;
8362 }
8363
8364 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
8365         if ((_res & 1) != 0) return;
8366         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8367         FREE((void*)_res);
8368         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
8369 }
8370
8371 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8372         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
8373         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
8374         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
8375         return (long)ret_conv;
8376 }
8377
8378 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8379         LDKUnsignedChannelUpdate o_conv;
8380         o_conv.inner = (void*)(o & (~1));
8381         o_conv.is_owned = (o & 1) || (o == 0);
8382         o_conv = UnsignedChannelUpdate_clone(&o_conv);
8383         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8384         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
8385         return (long)ret_conv;
8386 }
8387
8388 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
8389         LDKDecodeError e_conv;
8390         e_conv.inner = (void*)(e & (~1));
8391         e_conv.is_owned = (e & 1) || (e == 0);
8392         e_conv = DecodeError_clone(&e_conv);
8393         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8394         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
8395         return (long)ret_conv;
8396 }
8397
8398 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8399         if ((_res & 1) != 0) return;
8400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8401         FREE((void*)_res);
8402         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
8403 }
8404
8405 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8406         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
8407         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
8408         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
8409         return (long)ret_conv;
8410 }
8411
8412 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
8413         LDKChannelUpdate o_conv;
8414         o_conv.inner = (void*)(o & (~1));
8415         o_conv.is_owned = (o & 1) || (o == 0);
8416         o_conv = ChannelUpdate_clone(&o_conv);
8417         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8418         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
8419         return (long)ret_conv;
8420 }
8421
8422 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
8423         LDKDecodeError e_conv;
8424         e_conv.inner = (void*)(e & (~1));
8425         e_conv.is_owned = (e & 1) || (e == 0);
8426         e_conv = DecodeError_clone(&e_conv);
8427         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8428         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
8429         return (long)ret_conv;
8430 }
8431
8432 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
8433         if ((_res & 1) != 0) return;
8434         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
8435         FREE((void*)_res);
8436         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
8437 }
8438
8439 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
8440         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
8441         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
8442         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
8443         return (long)ret_conv;
8444 }
8445
8446 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
8447         LDKErrorMessage o_conv;
8448         o_conv.inner = (void*)(o & (~1));
8449         o_conv.is_owned = (o & 1) || (o == 0);
8450         o_conv = ErrorMessage_clone(&o_conv);
8451         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8452         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
8453         return (long)ret_conv;
8454 }
8455
8456 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
8457         LDKDecodeError e_conv;
8458         e_conv.inner = (void*)(e & (~1));
8459         e_conv.is_owned = (e & 1) || (e == 0);
8460         e_conv = DecodeError_clone(&e_conv);
8461         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8462         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
8463         return (long)ret_conv;
8464 }
8465
8466 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
8467         if ((_res & 1) != 0) return;
8468         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
8469         FREE((void*)_res);
8470         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
8471 }
8472
8473 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
8474         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
8475         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
8476         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
8477         return (long)ret_conv;
8478 }
8479
8480 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8481         LDKUnsignedNodeAnnouncement o_conv;
8482         o_conv.inner = (void*)(o & (~1));
8483         o_conv.is_owned = (o & 1) || (o == 0);
8484         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
8485         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8486         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
8487         return (long)ret_conv;
8488 }
8489
8490 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8491         LDKDecodeError e_conv;
8492         e_conv.inner = (void*)(e & (~1));
8493         e_conv.is_owned = (e & 1) || (e == 0);
8494         e_conv = DecodeError_clone(&e_conv);
8495         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8496         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
8497         return (long)ret_conv;
8498 }
8499
8500 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8501         if ((_res & 1) != 0) return;
8502         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8503         FREE((void*)_res);
8504         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
8505 }
8506
8507 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8508         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
8509         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
8510         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
8511         return (long)ret_conv;
8512 }
8513
8514 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
8515         LDKNodeAnnouncement o_conv;
8516         o_conv.inner = (void*)(o & (~1));
8517         o_conv.is_owned = (o & 1) || (o == 0);
8518         o_conv = NodeAnnouncement_clone(&o_conv);
8519         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8520         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
8521         return (long)ret_conv;
8522 }
8523
8524 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
8525         LDKDecodeError e_conv;
8526         e_conv.inner = (void*)(e & (~1));
8527         e_conv.is_owned = (e & 1) || (e == 0);
8528         e_conv = DecodeError_clone(&e_conv);
8529         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8530         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
8531         return (long)ret_conv;
8532 }
8533
8534 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
8535         if ((_res & 1) != 0) return;
8536         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
8537         FREE((void*)_res);
8538         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
8539 }
8540
8541 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
8542         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
8543         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
8544         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
8545         return (long)ret_conv;
8546 }
8547
8548 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
8549         LDKQueryShortChannelIds o_conv;
8550         o_conv.inner = (void*)(o & (~1));
8551         o_conv.is_owned = (o & 1) || (o == 0);
8552         o_conv = QueryShortChannelIds_clone(&o_conv);
8553         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8554         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
8555         return (long)ret_conv;
8556 }
8557
8558 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
8559         LDKDecodeError e_conv;
8560         e_conv.inner = (void*)(e & (~1));
8561         e_conv.is_owned = (e & 1) || (e == 0);
8562         e_conv = DecodeError_clone(&e_conv);
8563         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8564         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
8565         return (long)ret_conv;
8566 }
8567
8568 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
8569         if ((_res & 1) != 0) return;
8570         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
8571         FREE((void*)_res);
8572         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
8573 }
8574
8575 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
8576         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
8577         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
8578         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
8579         return (long)ret_conv;
8580 }
8581
8582 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
8583         LDKReplyShortChannelIdsEnd o_conv;
8584         o_conv.inner = (void*)(o & (~1));
8585         o_conv.is_owned = (o & 1) || (o == 0);
8586         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
8587         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8588         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
8589         return (long)ret_conv;
8590 }
8591
8592 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
8593         LDKDecodeError e_conv;
8594         e_conv.inner = (void*)(e & (~1));
8595         e_conv.is_owned = (e & 1) || (e == 0);
8596         e_conv = DecodeError_clone(&e_conv);
8597         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8598         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
8599         return (long)ret_conv;
8600 }
8601
8602 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
8603         if ((_res & 1) != 0) return;
8604         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
8605         FREE((void*)_res);
8606         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
8610         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
8611         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
8612         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
8613         return (long)ret_conv;
8614 }
8615
8616 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
8617         LDKQueryChannelRange o_conv;
8618         o_conv.inner = (void*)(o & (~1));
8619         o_conv.is_owned = (o & 1) || (o == 0);
8620         o_conv = QueryChannelRange_clone(&o_conv);
8621         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8622         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
8623         return (long)ret_conv;
8624 }
8625
8626 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
8627         LDKDecodeError e_conv;
8628         e_conv.inner = (void*)(e & (~1));
8629         e_conv.is_owned = (e & 1) || (e == 0);
8630         e_conv = DecodeError_clone(&e_conv);
8631         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8632         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
8633         return (long)ret_conv;
8634 }
8635
8636 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
8637         if ((_res & 1) != 0) return;
8638         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8639         FREE((void*)_res);
8640         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
8641 }
8642
8643 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8644         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
8645         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
8646         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
8647         return (long)ret_conv;
8648 }
8649
8650 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
8651         LDKReplyChannelRange o_conv;
8652         o_conv.inner = (void*)(o & (~1));
8653         o_conv.is_owned = (o & 1) || (o == 0);
8654         o_conv = ReplyChannelRange_clone(&o_conv);
8655         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8656         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
8657         return (long)ret_conv;
8658 }
8659
8660 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
8661         LDKDecodeError e_conv;
8662         e_conv.inner = (void*)(e & (~1));
8663         e_conv.is_owned = (e & 1) || (e == 0);
8664         e_conv = DecodeError_clone(&e_conv);
8665         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8666         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
8667         return (long)ret_conv;
8668 }
8669
8670 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
8671         if ((_res & 1) != 0) return;
8672         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
8673         FREE((void*)_res);
8674         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
8675 }
8676
8677 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
8678         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
8679         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
8680         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
8681         return (long)ret_conv;
8682 }
8683
8684 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
8685         LDKGossipTimestampFilter o_conv;
8686         o_conv.inner = (void*)(o & (~1));
8687         o_conv.is_owned = (o & 1) || (o == 0);
8688         o_conv = GossipTimestampFilter_clone(&o_conv);
8689         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8690         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
8691         return (long)ret_conv;
8692 }
8693
8694 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
8695         LDKDecodeError e_conv;
8696         e_conv.inner = (void*)(e & (~1));
8697         e_conv.is_owned = (e & 1) || (e == 0);
8698         e_conv = DecodeError_clone(&e_conv);
8699         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8700         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
8701         return (long)ret_conv;
8702 }
8703
8704 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
8705         if ((_res & 1) != 0) return;
8706         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
8707         FREE((void*)_res);
8708         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
8709 }
8710
8711 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
8712         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
8713         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
8714         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
8715         return (long)ret_conv;
8716 }
8717
8718 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
8719         if ((this_ptr & 1) != 0) return;
8720         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
8721         FREE((void*)this_ptr);
8722         Event_free(this_ptr_conv);
8723 }
8724
8725 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
8726         LDKEvent* orig_conv = (LDKEvent*)orig;
8727         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
8728         *ret_copy = Event_clone(orig_conv);
8729         long ret_ref = (long)ret_copy;
8730         return ret_ref;
8731 }
8732
8733 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
8734         LDKEvent* obj_conv = (LDKEvent*)obj;
8735         LDKCVec_u8Z ret_var = Event_write(obj_conv);
8736         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8737         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
8738         CVec_u8Z_free(ret_var);
8739         return ret_arr;
8740 }
8741
8742 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
8743         if ((this_ptr & 1) != 0) return;
8744         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
8745         FREE((void*)this_ptr);
8746         MessageSendEvent_free(this_ptr_conv);
8747 }
8748
8749 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
8750         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
8751         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8752         *ret_copy = MessageSendEvent_clone(orig_conv);
8753         long ret_ref = (long)ret_copy;
8754         return ret_ref;
8755 }
8756
8757 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
8758         if ((this_ptr & 1) != 0) return;
8759         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
8760         FREE((void*)this_ptr);
8761         MessageSendEventsProvider_free(this_ptr_conv);
8762 }
8763
8764 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
8765         if ((this_ptr & 1) != 0) return;
8766         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
8767         FREE((void*)this_ptr);
8768         EventsProvider_free(this_ptr_conv);
8769 }
8770
8771 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
8772         if ((this_ptr & 1) != 0) return;
8773         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
8774         FREE((void*)this_ptr);
8775         APIError_free(this_ptr_conv);
8776 }
8777
8778 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
8779         LDKAPIError* orig_conv = (LDKAPIError*)orig;
8780         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
8781         *ret_copy = APIError_clone(orig_conv);
8782         long ret_ref = (long)ret_copy;
8783         return ret_ref;
8784 }
8785
8786 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
8787         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
8788         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
8789         return ret_conv;
8790 }
8791
8792 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
8793         uint32_t ret_conv = LDKLevel_to_js(Level_max());
8794         return ret_conv;
8795 }
8796
8797 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
8798         if ((this_ptr & 1) != 0) return;
8799         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
8800         FREE((void*)this_ptr);
8801         Logger_free(this_ptr_conv);
8802 }
8803
8804 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
8805         LDKChannelHandshakeConfig this_obj_conv;
8806         this_obj_conv.inner = (void*)(this_obj & (~1));
8807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
8808         ChannelHandshakeConfig_free(this_obj_conv);
8809 }
8810
8811 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
8812         LDKChannelHandshakeConfig this_ptr_conv;
8813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8814         this_ptr_conv.is_owned = false;
8815         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
8816         return ret_val;
8817 }
8818
8819 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
8820         LDKChannelHandshakeConfig this_ptr_conv;
8821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8822         this_ptr_conv.is_owned = false;
8823         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
8824 }
8825
8826 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
8827         LDKChannelHandshakeConfig this_ptr_conv;
8828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8829         this_ptr_conv.is_owned = false;
8830         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
8831         return ret_val;
8832 }
8833
8834 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
8835         LDKChannelHandshakeConfig this_ptr_conv;
8836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8837         this_ptr_conv.is_owned = false;
8838         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
8839 }
8840
8841 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
8842         LDKChannelHandshakeConfig this_ptr_conv;
8843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8844         this_ptr_conv.is_owned = false;
8845         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
8846         return ret_val;
8847 }
8848
8849 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8850         LDKChannelHandshakeConfig this_ptr_conv;
8851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8852         this_ptr_conv.is_owned = false;
8853         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
8854 }
8855
8856 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) {
8857         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
8858         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8859         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8860         long ret_ref = (long)ret_var.inner;
8861         if (ret_var.is_owned) {
8862                 ret_ref |= 1;
8863         }
8864         return ret_ref;
8865 }
8866
8867 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
8868         LDKChannelHandshakeConfig orig_conv;
8869         orig_conv.inner = (void*)(orig & (~1));
8870         orig_conv.is_owned = false;
8871         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
8872         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8873         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8874         long ret_ref = (long)ret_var.inner;
8875         if (ret_var.is_owned) {
8876                 ret_ref |= 1;
8877         }
8878         return ret_ref;
8879 }
8880
8881 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
8882         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
8883         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8884         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8885         long ret_ref = (long)ret_var.inner;
8886         if (ret_var.is_owned) {
8887                 ret_ref |= 1;
8888         }
8889         return ret_ref;
8890 }
8891
8892 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
8893         LDKChannelHandshakeLimits this_obj_conv;
8894         this_obj_conv.inner = (void*)(this_obj & (~1));
8895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
8896         ChannelHandshakeLimits_free(this_obj_conv);
8897 }
8898
8899 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
8900         LDKChannelHandshakeLimits this_ptr_conv;
8901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8902         this_ptr_conv.is_owned = false;
8903         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
8904         return ret_val;
8905 }
8906
8907 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
8908         LDKChannelHandshakeLimits this_ptr_conv;
8909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8910         this_ptr_conv.is_owned = false;
8911         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
8912 }
8913
8914 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
8915         LDKChannelHandshakeLimits this_ptr_conv;
8916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8917         this_ptr_conv.is_owned = false;
8918         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
8919         return ret_val;
8920 }
8921
8922 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8923         LDKChannelHandshakeLimits this_ptr_conv;
8924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8925         this_ptr_conv.is_owned = false;
8926         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
8927 }
8928
8929 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8930         LDKChannelHandshakeLimits this_ptr_conv;
8931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8932         this_ptr_conv.is_owned = false;
8933         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
8934         return ret_val;
8935 }
8936
8937 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8938         LDKChannelHandshakeLimits this_ptr_conv;
8939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8940         this_ptr_conv.is_owned = false;
8941         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8942 }
8943
8944 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
8945         LDKChannelHandshakeLimits this_ptr_conv;
8946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8947         this_ptr_conv.is_owned = false;
8948         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
8949         return ret_val;
8950 }
8951
8952 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8953         LDKChannelHandshakeLimits this_ptr_conv;
8954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8955         this_ptr_conv.is_owned = false;
8956         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
8957 }
8958
8959 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
8960         LDKChannelHandshakeLimits this_ptr_conv;
8961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8962         this_ptr_conv.is_owned = false;
8963         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
8964         return ret_val;
8965 }
8966
8967 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
8968         LDKChannelHandshakeLimits this_ptr_conv;
8969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8970         this_ptr_conv.is_owned = false;
8971         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
8972 }
8973
8974 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
8975         LDKChannelHandshakeLimits this_ptr_conv;
8976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8977         this_ptr_conv.is_owned = false;
8978         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
8979         return ret_val;
8980 }
8981
8982 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8983         LDKChannelHandshakeLimits this_ptr_conv;
8984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8985         this_ptr_conv.is_owned = false;
8986         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
8987 }
8988
8989 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
8990         LDKChannelHandshakeLimits this_ptr_conv;
8991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8992         this_ptr_conv.is_owned = false;
8993         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
8994         return ret_val;
8995 }
8996
8997 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8998         LDKChannelHandshakeLimits this_ptr_conv;
8999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9000         this_ptr_conv.is_owned = false;
9001         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
9002 }
9003
9004 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
9005         LDKChannelHandshakeLimits this_ptr_conv;
9006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9007         this_ptr_conv.is_owned = false;
9008         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
9009         return ret_val;
9010 }
9011
9012 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
9013         LDKChannelHandshakeLimits this_ptr_conv;
9014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9015         this_ptr_conv.is_owned = false;
9016         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
9017 }
9018
9019 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
9020         LDKChannelHandshakeLimits this_ptr_conv;
9021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9022         this_ptr_conv.is_owned = false;
9023         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
9024         return ret_val;
9025 }
9026
9027 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
9028         LDKChannelHandshakeLimits this_ptr_conv;
9029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9030         this_ptr_conv.is_owned = false;
9031         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
9032 }
9033
9034 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
9035         LDKChannelHandshakeLimits this_ptr_conv;
9036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9037         this_ptr_conv.is_owned = false;
9038         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
9039         return ret_val;
9040 }
9041
9042 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
9043         LDKChannelHandshakeLimits this_ptr_conv;
9044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9045         this_ptr_conv.is_owned = false;
9046         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
9047 }
9048
9049 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) {
9050         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);
9051         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9052         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9053         long ret_ref = (long)ret_var.inner;
9054         if (ret_var.is_owned) {
9055                 ret_ref |= 1;
9056         }
9057         return ret_ref;
9058 }
9059
9060 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
9061         LDKChannelHandshakeLimits orig_conv;
9062         orig_conv.inner = (void*)(orig & (~1));
9063         orig_conv.is_owned = false;
9064         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
9065         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9066         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9067         long ret_ref = (long)ret_var.inner;
9068         if (ret_var.is_owned) {
9069                 ret_ref |= 1;
9070         }
9071         return ret_ref;
9072 }
9073
9074 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
9075         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
9076         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9077         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9078         long ret_ref = (long)ret_var.inner;
9079         if (ret_var.is_owned) {
9080                 ret_ref |= 1;
9081         }
9082         return ret_ref;
9083 }
9084
9085 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
9086         LDKChannelConfig this_obj_conv;
9087         this_obj_conv.inner = (void*)(this_obj & (~1));
9088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9089         ChannelConfig_free(this_obj_conv);
9090 }
9091
9092 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
9093         LDKChannelConfig this_ptr_conv;
9094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9095         this_ptr_conv.is_owned = false;
9096         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
9097         return ret_val;
9098 }
9099
9100 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
9101         LDKChannelConfig this_ptr_conv;
9102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9103         this_ptr_conv.is_owned = false;
9104         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
9105 }
9106
9107 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
9108         LDKChannelConfig this_ptr_conv;
9109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9110         this_ptr_conv.is_owned = false;
9111         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
9112         return ret_val;
9113 }
9114
9115 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
9116         LDKChannelConfig this_ptr_conv;
9117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9118         this_ptr_conv.is_owned = false;
9119         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
9120 }
9121
9122 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
9123         LDKChannelConfig this_ptr_conv;
9124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9125         this_ptr_conv.is_owned = false;
9126         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
9127         return ret_val;
9128 }
9129
9130 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
9131         LDKChannelConfig this_ptr_conv;
9132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9133         this_ptr_conv.is_owned = false;
9134         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
9135 }
9136
9137 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
9138         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
9139         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9140         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9141         long ret_ref = (long)ret_var.inner;
9142         if (ret_var.is_owned) {
9143                 ret_ref |= 1;
9144         }
9145         return ret_ref;
9146 }
9147
9148 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
9149         LDKChannelConfig orig_conv;
9150         orig_conv.inner = (void*)(orig & (~1));
9151         orig_conv.is_owned = false;
9152         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
9153         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9154         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9155         long ret_ref = (long)ret_var.inner;
9156         if (ret_var.is_owned) {
9157                 ret_ref |= 1;
9158         }
9159         return ret_ref;
9160 }
9161
9162 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
9163         LDKChannelConfig ret_var = ChannelConfig_default();
9164         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9165         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9166         long ret_ref = (long)ret_var.inner;
9167         if (ret_var.is_owned) {
9168                 ret_ref |= 1;
9169         }
9170         return ret_ref;
9171 }
9172
9173 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
9174         LDKChannelConfig obj_conv;
9175         obj_conv.inner = (void*)(obj & (~1));
9176         obj_conv.is_owned = false;
9177         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
9178         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9179         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9180         CVec_u8Z_free(ret_var);
9181         return ret_arr;
9182 }
9183
9184 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
9185         LDKu8slice ser_ref;
9186         ser_ref.datalen = *((uint32_t*)ser);
9187         ser_ref.data = (int8_t*)(ser + 4);
9188         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9189         *ret_conv = ChannelConfig_read(ser_ref);
9190         return (long)ret_conv;
9191 }
9192
9193 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
9194         LDKUserConfig this_obj_conv;
9195         this_obj_conv.inner = (void*)(this_obj & (~1));
9196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9197         UserConfig_free(this_obj_conv);
9198 }
9199
9200 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
9201         LDKUserConfig this_ptr_conv;
9202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9203         this_ptr_conv.is_owned = false;
9204         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
9205         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9206         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9207         long ret_ref = (long)ret_var.inner;
9208         if (ret_var.is_owned) {
9209                 ret_ref |= 1;
9210         }
9211         return ret_ref;
9212 }
9213
9214 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
9215         LDKUserConfig this_ptr_conv;
9216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9217         this_ptr_conv.is_owned = false;
9218         LDKChannelHandshakeConfig val_conv;
9219         val_conv.inner = (void*)(val & (~1));
9220         val_conv.is_owned = (val & 1) || (val == 0);
9221         val_conv = ChannelHandshakeConfig_clone(&val_conv);
9222         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
9223 }
9224
9225 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
9226         LDKUserConfig this_ptr_conv;
9227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9228         this_ptr_conv.is_owned = false;
9229         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
9230         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9231         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9232         long ret_ref = (long)ret_var.inner;
9233         if (ret_var.is_owned) {
9234                 ret_ref |= 1;
9235         }
9236         return ret_ref;
9237 }
9238
9239 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
9240         LDKUserConfig this_ptr_conv;
9241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9242         this_ptr_conv.is_owned = false;
9243         LDKChannelHandshakeLimits val_conv;
9244         val_conv.inner = (void*)(val & (~1));
9245         val_conv.is_owned = (val & 1) || (val == 0);
9246         val_conv = ChannelHandshakeLimits_clone(&val_conv);
9247         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
9248 }
9249
9250 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
9251         LDKUserConfig this_ptr_conv;
9252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9253         this_ptr_conv.is_owned = false;
9254         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_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 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
9265         LDKUserConfig this_ptr_conv;
9266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9267         this_ptr_conv.is_owned = false;
9268         LDKChannelConfig val_conv;
9269         val_conv.inner = (void*)(val & (~1));
9270         val_conv.is_owned = (val & 1) || (val == 0);
9271         val_conv = ChannelConfig_clone(&val_conv);
9272         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
9273 }
9274
9275 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) {
9276         LDKChannelHandshakeConfig own_channel_config_arg_conv;
9277         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
9278         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
9279         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
9280         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
9281         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
9282         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
9283         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
9284         LDKChannelConfig channel_options_arg_conv;
9285         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
9286         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
9287         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
9288         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
9289         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9290         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9291         long ret_ref = (long)ret_var.inner;
9292         if (ret_var.is_owned) {
9293                 ret_ref |= 1;
9294         }
9295         return ret_ref;
9296 }
9297
9298 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
9299         LDKUserConfig orig_conv;
9300         orig_conv.inner = (void*)(orig & (~1));
9301         orig_conv.is_owned = false;
9302         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
9303         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9304         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9305         long ret_ref = (long)ret_var.inner;
9306         if (ret_var.is_owned) {
9307                 ret_ref |= 1;
9308         }
9309         return ret_ref;
9310 }
9311
9312 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
9313         LDKUserConfig ret_var = UserConfig_default();
9314         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9315         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9316         long ret_ref = (long)ret_var.inner;
9317         if (ret_var.is_owned) {
9318                 ret_ref |= 1;
9319         }
9320         return ret_ref;
9321 }
9322
9323 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
9324         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
9325         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
9326         return ret_conv;
9327 }
9328
9329 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
9330         if ((this_ptr & 1) != 0) return;
9331         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
9332         FREE((void*)this_ptr);
9333         Access_free(this_ptr_conv);
9334 }
9335
9336 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
9337         if ((this_ptr & 1) != 0) return;
9338         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
9339         FREE((void*)this_ptr);
9340         Listen_free(this_ptr_conv);
9341 }
9342
9343 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
9344         if ((this_ptr & 1) != 0) return;
9345         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
9346         FREE((void*)this_ptr);
9347         Watch_free(this_ptr_conv);
9348 }
9349
9350 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
9351         if ((this_ptr & 1) != 0) return;
9352         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
9353         FREE((void*)this_ptr);
9354         Filter_free(this_ptr_conv);
9355 }
9356
9357 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
9358         if ((this_ptr & 1) != 0) return;
9359         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
9360         FREE((void*)this_ptr);
9361         BroadcasterInterface_free(this_ptr_conv);
9362 }
9363
9364 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
9365         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
9366         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
9367         return ret_conv;
9368 }
9369
9370 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
9371         if ((this_ptr & 1) != 0) return;
9372         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
9373         FREE((void*)this_ptr);
9374         FeeEstimator_free(this_ptr_conv);
9375 }
9376
9377 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
9378         LDKChainMonitor this_obj_conv;
9379         this_obj_conv.inner = (void*)(this_obj & (~1));
9380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9381         ChainMonitor_free(this_obj_conv);
9382 }
9383
9384 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9385         LDKChainMonitor this_arg_conv;
9386         this_arg_conv.inner = (void*)(this_arg & (~1));
9387         this_arg_conv.is_owned = false;
9388         unsigned char header_arr[80];
9389         CHECK(*((uint32_t*)header) == 80);
9390         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9391         unsigned char (*header_ref)[80] = &header_arr;
9392         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9393         txdata_constr.datalen = *((uint32_t*)txdata);
9394         if (txdata_constr.datalen > 0)
9395                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9396         else
9397                 txdata_constr.data = NULL;
9398         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9399         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9400                 uint32_t txdata_conv_30 = txdata_vals[e];
9401                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9402                 FREE((void*)txdata_conv_30);
9403                 txdata_constr.data[e] = txdata_conv_30_conv;
9404         }
9405         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
9406 }
9407
9408 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
9409         LDKChainMonitor this_arg_conv;
9410         this_arg_conv.inner = (void*)(this_arg & (~1));
9411         this_arg_conv.is_owned = false;
9412         unsigned char header_arr[80];
9413         CHECK(*((uint32_t*)header) == 80);
9414         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9415         unsigned char (*header_ref)[80] = &header_arr;
9416         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
9417 }
9418
9419 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
9420         LDKFilter *chain_source_conv_ptr = NULL;
9421         if (chain_source != 0) {
9422                 LDKFilter chain_source_conv;
9423                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
9424                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9425                 *chain_source_conv_ptr = chain_source_conv;
9426         }
9427         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9428         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9429         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
9430         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
9431         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
9432         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9433         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9434         long ret_ref = (long)ret_var.inner;
9435         if (ret_var.is_owned) {
9436                 ret_ref |= 1;
9437         }
9438         return ret_ref;
9439 }
9440
9441 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
9442         LDKChainMonitor this_arg_conv;
9443         this_arg_conv.inner = (void*)(this_arg & (~1));
9444         this_arg_conv.is_owned = false;
9445         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
9446         *ret = ChainMonitor_as_Watch(&this_arg_conv);
9447         return (long)ret;
9448 }
9449
9450 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
9451         LDKChainMonitor this_arg_conv;
9452         this_arg_conv.inner = (void*)(this_arg & (~1));
9453         this_arg_conv.is_owned = false;
9454         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9455         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
9456         return (long)ret;
9457 }
9458
9459 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
9460         LDKChannelMonitorUpdate this_obj_conv;
9461         this_obj_conv.inner = (void*)(this_obj & (~1));
9462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9463         ChannelMonitorUpdate_free(this_obj_conv);
9464 }
9465
9466 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
9467         LDKChannelMonitorUpdate this_ptr_conv;
9468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9469         this_ptr_conv.is_owned = false;
9470         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
9471         return ret_val;
9472 }
9473
9474 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
9475         LDKChannelMonitorUpdate this_ptr_conv;
9476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9477         this_ptr_conv.is_owned = false;
9478         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
9479 }
9480
9481 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
9482         LDKChannelMonitorUpdate orig_conv;
9483         orig_conv.inner = (void*)(orig & (~1));
9484         orig_conv.is_owned = false;
9485         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
9486         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9487         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9488         long ret_ref = (long)ret_var.inner;
9489         if (ret_var.is_owned) {
9490                 ret_ref |= 1;
9491         }
9492         return ret_ref;
9493 }
9494
9495 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
9496         LDKChannelMonitorUpdate obj_conv;
9497         obj_conv.inner = (void*)(obj & (~1));
9498         obj_conv.is_owned = false;
9499         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
9500         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9501         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9502         CVec_u8Z_free(ret_var);
9503         return ret_arr;
9504 }
9505
9506 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
9507         LDKu8slice ser_ref;
9508         ser_ref.datalen = *((uint32_t*)ser);
9509         ser_ref.data = (int8_t*)(ser + 4);
9510         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9511         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
9512         return (long)ret_conv;
9513 }
9514
9515 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
9516         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
9517         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
9518         return ret_conv;
9519 }
9520
9521 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
9522         LDKMonitorUpdateError this_obj_conv;
9523         this_obj_conv.inner = (void*)(this_obj & (~1));
9524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9525         MonitorUpdateError_free(this_obj_conv);
9526 }
9527
9528 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
9529         LDKMonitorUpdateError orig_conv;
9530         orig_conv.inner = (void*)(orig & (~1));
9531         orig_conv.is_owned = false;
9532         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
9533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9535         long ret_ref = (long)ret_var.inner;
9536         if (ret_var.is_owned) {
9537                 ret_ref |= 1;
9538         }
9539         return ret_ref;
9540 }
9541
9542 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
9543         if ((this_ptr & 1) != 0) return;
9544         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
9545         FREE((void*)this_ptr);
9546         MonitorEvent_free(this_ptr_conv);
9547 }
9548
9549 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
9550         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
9551         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
9552         *ret_copy = MonitorEvent_clone(orig_conv);
9553         long ret_ref = (long)ret_copy;
9554         return ret_ref;
9555 }
9556
9557 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
9558         LDKHTLCUpdate this_obj_conv;
9559         this_obj_conv.inner = (void*)(this_obj & (~1));
9560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9561         HTLCUpdate_free(this_obj_conv);
9562 }
9563
9564 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
9565         LDKHTLCUpdate orig_conv;
9566         orig_conv.inner = (void*)(orig & (~1));
9567         orig_conv.is_owned = false;
9568         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
9569         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9570         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9571         long ret_ref = (long)ret_var.inner;
9572         if (ret_var.is_owned) {
9573                 ret_ref |= 1;
9574         }
9575         return ret_ref;
9576 }
9577
9578 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
9579         LDKHTLCUpdate obj_conv;
9580         obj_conv.inner = (void*)(obj & (~1));
9581         obj_conv.is_owned = false;
9582         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
9583         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9584         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9585         CVec_u8Z_free(ret_var);
9586         return ret_arr;
9587 }
9588
9589 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
9590         LDKu8slice ser_ref;
9591         ser_ref.datalen = *((uint32_t*)ser);
9592         ser_ref.data = (int8_t*)(ser + 4);
9593         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9594         *ret_conv = HTLCUpdate_read(ser_ref);
9595         return (long)ret_conv;
9596 }
9597
9598 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
9599         LDKChannelMonitor this_obj_conv;
9600         this_obj_conv.inner = (void*)(this_obj & (~1));
9601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9602         ChannelMonitor_free(this_obj_conv);
9603 }
9604
9605 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
9606         LDKChannelMonitor orig_conv;
9607         orig_conv.inner = (void*)(orig & (~1));
9608         orig_conv.is_owned = false;
9609         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
9610         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9611         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9612         long ret_ref = (long)ret_var.inner;
9613         if (ret_var.is_owned) {
9614                 ret_ref |= 1;
9615         }
9616         return ret_ref;
9617 }
9618
9619 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
9620         LDKChannelMonitor obj_conv;
9621         obj_conv.inner = (void*)(obj & (~1));
9622         obj_conv.is_owned = false;
9623         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
9624         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9625         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9626         CVec_u8Z_free(ret_var);
9627         return ret_arr;
9628 }
9629
9630 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) {
9631         LDKChannelMonitor this_arg_conv;
9632         this_arg_conv.inner = (void*)(this_arg & (~1));
9633         this_arg_conv.is_owned = false;
9634         LDKChannelMonitorUpdate updates_conv;
9635         updates_conv.inner = (void*)(updates & (~1));
9636         updates_conv.is_owned = false;
9637         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9638         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9639         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
9640         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9641         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
9642         return (long)ret_conv;
9643 }
9644
9645 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
9646         LDKChannelMonitor this_arg_conv;
9647         this_arg_conv.inner = (void*)(this_arg & (~1));
9648         this_arg_conv.is_owned = false;
9649         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
9650         return ret_val;
9651 }
9652
9653 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
9654         LDKChannelMonitor this_arg_conv;
9655         this_arg_conv.inner = (void*)(this_arg & (~1));
9656         this_arg_conv.is_owned = false;
9657         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9658         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
9659         return (long)ret_ref;
9660 }
9661
9662 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
9663         LDKChannelMonitor this_arg_conv;
9664         this_arg_conv.inner = (void*)(this_arg & (~1));
9665         this_arg_conv.is_owned = false;
9666         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
9667         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9668         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9669         for (size_t c = 0; c < ret_var.datalen; c++) {
9670                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_54_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9671                 *ret_conv_54_ref = ret_var.data[c];
9672                 ret_arr_ptr[c] = (long)ret_conv_54_ref;
9673         }
9674         FREE(ret_var.data);
9675         return ret_arr;
9676 }
9677
9678 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
9679         LDKChannelMonitor this_arg_conv;
9680         this_arg_conv.inner = (void*)(this_arg & (~1));
9681         this_arg_conv.is_owned = false;
9682         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
9683         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
9684 }
9685
9686 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
9687         LDKChannelMonitor this_arg_conv;
9688         this_arg_conv.inner = (void*)(this_arg & (~1));
9689         this_arg_conv.is_owned = false;
9690         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
9691         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9692         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9693         for (size_t o = 0; o < ret_var.datalen; o++) {
9694                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
9695                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
9696                 long ret_conv_14_ref = (long)ret_conv_14_copy;
9697                 ret_arr_ptr[o] = ret_conv_14_ref;
9698         }
9699         FREE(ret_var.data);
9700         return ret_arr;
9701 }
9702
9703 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
9704         LDKChannelMonitor this_arg_conv;
9705         this_arg_conv.inner = (void*)(this_arg & (~1));
9706         this_arg_conv.is_owned = false;
9707         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
9708         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9709         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9710         for (size_t h = 0; h < ret_var.datalen; h++) {
9711                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
9712                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
9713                 long ret_conv_7_ref = (long)ret_conv_7_copy;
9714                 ret_arr_ptr[h] = ret_conv_7_ref;
9715         }
9716         FREE(ret_var.data);
9717         return ret_arr;
9718 }
9719
9720 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
9721         LDKChannelMonitor this_arg_conv;
9722         this_arg_conv.inner = (void*)(this_arg & (~1));
9723         this_arg_conv.is_owned = false;
9724         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
9725         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
9726         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
9727         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
9728         for (size_t m = 0; m < ret_var.datalen; m++) {
9729                 LDKTransaction ret_conv_12_var = ret_var.data[m];
9730                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9731                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
9732                 Transaction_free(ret_conv_12_var);
9733                 ret_arr_ptr[m] = ret_conv_12_arr;
9734         }
9735         FREE(ret_var.data);
9736         return ret_arr;
9737 }
9738
9739 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) {
9740         LDKChannelMonitor this_arg_conv;
9741         this_arg_conv.inner = (void*)(this_arg & (~1));
9742         this_arg_conv.is_owned = false;
9743         unsigned char header_arr[80];
9744         CHECK(*((uint32_t*)header) == 80);
9745         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9746         unsigned char (*header_ref)[80] = &header_arr;
9747         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9748         txdata_constr.datalen = *((uint32_t*)txdata);
9749         if (txdata_constr.datalen > 0)
9750                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9751         else
9752                 txdata_constr.data = NULL;
9753         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
9754         for (size_t e = 0; e < txdata_constr.datalen; e++) {
9755                 uint32_t txdata_conv_30 = txdata_vals[e];
9756                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
9757                 FREE((void*)txdata_conv_30);
9758                 txdata_constr.data[e] = txdata_conv_30_conv;
9759         }
9760         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9761         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9762         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9763         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);
9764         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
9765         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
9766         for (size_t x = 0; x < ret_var.datalen; x++) {
9767                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9768                 *ret_conv_49_ref = ret_var.data[x];
9769                 ret_arr_ptr[x] = (long)ret_conv_49_ref;
9770         }
9771         FREE(ret_var.data);
9772         return ret_arr;
9773 }
9774
9775 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) {
9776         LDKChannelMonitor this_arg_conv;
9777         this_arg_conv.inner = (void*)(this_arg & (~1));
9778         this_arg_conv.is_owned = false;
9779         unsigned char header_arr[80];
9780         CHECK(*((uint32_t*)header) == 80);
9781         memcpy(header_arr, (uint8_t*)(header + 4), 80);
9782         unsigned char (*header_ref)[80] = &header_arr;
9783         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
9784         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
9785         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
9786         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
9787 }
9788
9789 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
9790         if ((this_ptr & 1) != 0) return;
9791         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
9792         FREE((void*)this_ptr);
9793         Persist_free(this_ptr_conv);
9794 }
9795
9796 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
9797         LDKu8slice ser_ref;
9798         ser_ref.datalen = *((uint32_t*)ser);
9799         ser_ref.data = (int8_t*)(ser + 4);
9800         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
9801         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
9802         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
9803         return (long)ret_conv;
9804 }
9805
9806 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
9807         LDKOutPoint this_obj_conv;
9808         this_obj_conv.inner = (void*)(this_obj & (~1));
9809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9810         OutPoint_free(this_obj_conv);
9811 }
9812
9813 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
9814         LDKOutPoint this_ptr_conv;
9815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9816         this_ptr_conv.is_owned = false;
9817         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9818         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
9819         return ret_arr;
9820 }
9821
9822 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
9823         LDKOutPoint this_ptr_conv;
9824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9825         this_ptr_conv.is_owned = false;
9826         LDKThirtyTwoBytes val_ref;
9827         CHECK(*((uint32_t*)val) == 32);
9828         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9829         OutPoint_set_txid(&this_ptr_conv, val_ref);
9830 }
9831
9832 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
9833         LDKOutPoint this_ptr_conv;
9834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9835         this_ptr_conv.is_owned = false;
9836         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
9837         return ret_val;
9838 }
9839
9840 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
9841         LDKOutPoint this_ptr_conv;
9842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9843         this_ptr_conv.is_owned = false;
9844         OutPoint_set_index(&this_ptr_conv, val);
9845 }
9846
9847 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
9848         LDKThirtyTwoBytes txid_arg_ref;
9849         CHECK(*((uint32_t*)txid_arg) == 32);
9850         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
9851         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
9852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9854         long ret_ref = (long)ret_var.inner;
9855         if (ret_var.is_owned) {
9856                 ret_ref |= 1;
9857         }
9858         return ret_ref;
9859 }
9860
9861 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
9862         LDKOutPoint orig_conv;
9863         orig_conv.inner = (void*)(orig & (~1));
9864         orig_conv.is_owned = false;
9865         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
9866         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9867         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9868         long ret_ref = (long)ret_var.inner;
9869         if (ret_var.is_owned) {
9870                 ret_ref |= 1;
9871         }
9872         return ret_ref;
9873 }
9874
9875 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
9876         LDKOutPoint this_arg_conv;
9877         this_arg_conv.inner = (void*)(this_arg & (~1));
9878         this_arg_conv.is_owned = false;
9879         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9880         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
9881         return ret_arr;
9882 }
9883
9884 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
9885         LDKOutPoint obj_conv;
9886         obj_conv.inner = (void*)(obj & (~1));
9887         obj_conv.is_owned = false;
9888         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
9889         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9890         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
9891         CVec_u8Z_free(ret_var);
9892         return ret_arr;
9893 }
9894
9895 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
9896         LDKu8slice ser_ref;
9897         ser_ref.datalen = *((uint32_t*)ser);
9898         ser_ref.data = (int8_t*)(ser + 4);
9899         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9900         *ret_conv = OutPoint_read(ser_ref);
9901         return (long)ret_conv;
9902 }
9903
9904 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
9905         LDKDelayedPaymentOutputDescriptor this_obj_conv;
9906         this_obj_conv.inner = (void*)(this_obj & (~1));
9907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
9908         DelayedPaymentOutputDescriptor_free(this_obj_conv);
9909 }
9910
9911 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
9912         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9914         this_ptr_conv.is_owned = false;
9915         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
9916         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9917         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9918         long ret_ref = (long)ret_var.inner;
9919         if (ret_var.is_owned) {
9920                 ret_ref |= 1;
9921         }
9922         return ret_ref;
9923 }
9924
9925 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
9926         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9928         this_ptr_conv.is_owned = false;
9929         LDKOutPoint val_conv;
9930         val_conv.inner = (void*)(val & (~1));
9931         val_conv.is_owned = (val & 1) || (val == 0);
9932         val_conv = OutPoint_clone(&val_conv);
9933         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
9934 }
9935
9936 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
9937         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9939         this_ptr_conv.is_owned = false;
9940         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9941         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9942         return ret_arr;
9943 }
9944
9945 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9946         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9948         this_ptr_conv.is_owned = false;
9949         LDKPublicKey val_ref;
9950         CHECK(*((uint32_t*)val) == 33);
9951         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9952         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
9953 }
9954
9955 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
9956         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9958         this_ptr_conv.is_owned = false;
9959         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
9960         return ret_val;
9961 }
9962
9963 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
9964         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9966         this_ptr_conv.is_owned = false;
9967         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
9968 }
9969
9970 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
9971         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9973         this_ptr_conv.is_owned = false;
9974         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
9975         FREE((void*)val);
9976         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
9977 }
9978
9979 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
9980         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9982         this_ptr_conv.is_owned = false;
9983         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9984         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
9985         return ret_arr;
9986 }
9987
9988 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
9989         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
9990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9991         this_ptr_conv.is_owned = false;
9992         LDKPublicKey val_ref;
9993         CHECK(*((uint32_t*)val) == 33);
9994         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9995         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
9996 }
9997
9998 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
9999         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10001         this_ptr_conv.is_owned = false;
10002         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10003         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10004         return ret_arr;
10005 }
10006
10007 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10008         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10010         this_ptr_conv.is_owned = false;
10011         LDKThirtyTwoBytes val_ref;
10012         CHECK(*((uint32_t*)val) == 32);
10013         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10014         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10015 }
10016
10017 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10020         this_ptr_conv.is_owned = false;
10021         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10022         return ret_val;
10023 }
10024
10025 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10026         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
10027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10028         this_ptr_conv.is_owned = false;
10029         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10030 }
10031
10032 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) {
10033         LDKOutPoint outpoint_arg_conv;
10034         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10035         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10036         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10037         LDKPublicKey per_commitment_point_arg_ref;
10038         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
10039         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
10040         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10041         FREE((void*)output_arg);
10042         LDKPublicKey revocation_pubkey_arg_ref;
10043         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
10044         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
10045         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10046         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10047         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10048         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);
10049         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10050         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10051         long ret_ref = (long)ret_var.inner;
10052         if (ret_var.is_owned) {
10053                 ret_ref |= 1;
10054         }
10055         return ret_ref;
10056 }
10057
10058 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
10059         LDKDelayedPaymentOutputDescriptor orig_conv;
10060         orig_conv.inner = (void*)(orig & (~1));
10061         orig_conv.is_owned = false;
10062         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
10063         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10064         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10065         long ret_ref = (long)ret_var.inner;
10066         if (ret_var.is_owned) {
10067                 ret_ref |= 1;
10068         }
10069         return ret_ref;
10070 }
10071
10072 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
10073         LDKStaticPaymentOutputDescriptor this_obj_conv;
10074         this_obj_conv.inner = (void*)(this_obj & (~1));
10075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10076         StaticPaymentOutputDescriptor_free(this_obj_conv);
10077 }
10078
10079 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
10080         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10082         this_ptr_conv.is_owned = false;
10083         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
10084         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10085         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10086         long ret_ref = (long)ret_var.inner;
10087         if (ret_var.is_owned) {
10088                 ret_ref |= 1;
10089         }
10090         return ret_ref;
10091 }
10092
10093 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
10094         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10096         this_ptr_conv.is_owned = false;
10097         LDKOutPoint val_conv;
10098         val_conv.inner = (void*)(val & (~1));
10099         val_conv.is_owned = (val & 1) || (val == 0);
10100         val_conv = OutPoint_clone(&val_conv);
10101         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
10102 }
10103
10104 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
10105         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10107         this_ptr_conv.is_owned = false;
10108         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
10109         FREE((void*)val);
10110         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
10111 }
10112
10113 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
10114         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10116         this_ptr_conv.is_owned = false;
10117         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10118         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
10119         return ret_arr;
10120 }
10121
10122 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
10123         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10125         this_ptr_conv.is_owned = false;
10126         LDKThirtyTwoBytes val_ref;
10127         CHECK(*((uint32_t*)val) == 32);
10128         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10129         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
10130 }
10131
10132 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
10133         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10135         this_ptr_conv.is_owned = false;
10136         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
10137         return ret_val;
10138 }
10139
10140 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10141         LDKStaticPaymentOutputDescriptor this_ptr_conv;
10142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10143         this_ptr_conv.is_owned = false;
10144         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
10145 }
10146
10147 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) {
10148         LDKOutPoint outpoint_arg_conv;
10149         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
10150         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
10151         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
10152         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
10153         FREE((void*)output_arg);
10154         LDKThirtyTwoBytes channel_keys_id_arg_ref;
10155         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
10156         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
10157         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
10158         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10159         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10160         long ret_ref = (long)ret_var.inner;
10161         if (ret_var.is_owned) {
10162                 ret_ref |= 1;
10163         }
10164         return ret_ref;
10165 }
10166
10167 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
10168         LDKStaticPaymentOutputDescriptor orig_conv;
10169         orig_conv.inner = (void*)(orig & (~1));
10170         orig_conv.is_owned = false;
10171         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
10172         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10173         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10174         long ret_ref = (long)ret_var.inner;
10175         if (ret_var.is_owned) {
10176                 ret_ref |= 1;
10177         }
10178         return ret_ref;
10179 }
10180
10181 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
10182         if ((this_ptr & 1) != 0) return;
10183         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
10184         FREE((void*)this_ptr);
10185         SpendableOutputDescriptor_free(this_ptr_conv);
10186 }
10187
10188 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
10189         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
10190         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
10191         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
10192         long ret_ref = (long)ret_copy;
10193         return ret_ref;
10194 }
10195
10196 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
10197         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
10198         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
10199         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10200         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10201         CVec_u8Z_free(ret_var);
10202         return ret_arr;
10203 }
10204
10205 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
10206         LDKu8slice ser_ref;
10207         ser_ref.datalen = *((uint32_t*)ser);
10208         ser_ref.data = (int8_t*)(ser + 4);
10209         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10210         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
10211         return (long)ret_conv;
10212 }
10213
10214 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
10215         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
10216         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10217         *ret = Sign_clone(orig_conv);
10218         return (long)ret;
10219 }
10220
10221 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
10222         if ((this_ptr & 1) != 0) return;
10223         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
10224         FREE((void*)this_ptr);
10225         Sign_free(this_ptr_conv);
10226 }
10227
10228 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
10229         if ((this_ptr & 1) != 0) return;
10230         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
10231         FREE((void*)this_ptr);
10232         KeysInterface_free(this_ptr_conv);
10233 }
10234
10235 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
10236         LDKInMemorySigner this_obj_conv;
10237         this_obj_conv.inner = (void*)(this_obj & (~1));
10238         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10239         InMemorySigner_free(this_obj_conv);
10240 }
10241
10242 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
10243         LDKInMemorySigner this_ptr_conv;
10244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10245         this_ptr_conv.is_owned = false;
10246         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10247         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
10248         return ret_arr;
10249 }
10250
10251 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
10252         LDKInMemorySigner this_ptr_conv;
10253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10254         this_ptr_conv.is_owned = false;
10255         LDKSecretKey val_ref;
10256         CHECK(*((uint32_t*)val) == 32);
10257         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10258         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
10259 }
10260
10261 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
10262         LDKInMemorySigner this_ptr_conv;
10263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10264         this_ptr_conv.is_owned = false;
10265         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10266         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
10267         return ret_arr;
10268 }
10269
10270 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
10271         LDKInMemorySigner this_ptr_conv;
10272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10273         this_ptr_conv.is_owned = false;
10274         LDKSecretKey val_ref;
10275         CHECK(*((uint32_t*)val) == 32);
10276         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10277         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
10278 }
10279
10280 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
10281         LDKInMemorySigner this_ptr_conv;
10282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10283         this_ptr_conv.is_owned = false;
10284         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10285         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
10286         return ret_arr;
10287 }
10288
10289 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
10290         LDKInMemorySigner this_ptr_conv;
10291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10292         this_ptr_conv.is_owned = false;
10293         LDKSecretKey val_ref;
10294         CHECK(*((uint32_t*)val) == 32);
10295         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10296         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
10297 }
10298
10299 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
10300         LDKInMemorySigner this_ptr_conv;
10301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10302         this_ptr_conv.is_owned = false;
10303         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10304         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
10305         return ret_arr;
10306 }
10307
10308 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
10309         LDKInMemorySigner this_ptr_conv;
10310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10311         this_ptr_conv.is_owned = false;
10312         LDKSecretKey val_ref;
10313         CHECK(*((uint32_t*)val) == 32);
10314         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10315         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
10316 }
10317
10318 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
10319         LDKInMemorySigner this_ptr_conv;
10320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10321         this_ptr_conv.is_owned = false;
10322         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10323         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
10324         return ret_arr;
10325 }
10326
10327 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
10328         LDKInMemorySigner this_ptr_conv;
10329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10330         this_ptr_conv.is_owned = false;
10331         LDKSecretKey val_ref;
10332         CHECK(*((uint32_t*)val) == 32);
10333         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
10334         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
10335 }
10336
10337 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
10338         LDKInMemorySigner this_ptr_conv;
10339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10340         this_ptr_conv.is_owned = false;
10341         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10342         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
10343         return ret_arr;
10344 }
10345
10346 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
10347         LDKInMemorySigner this_ptr_conv;
10348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10349         this_ptr_conv.is_owned = false;
10350         LDKThirtyTwoBytes val_ref;
10351         CHECK(*((uint32_t*)val) == 32);
10352         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10353         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
10354 }
10355
10356 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
10357         LDKInMemorySigner orig_conv;
10358         orig_conv.inner = (void*)(orig & (~1));
10359         orig_conv.is_owned = false;
10360         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
10361         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10362         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10363         long ret_ref = (long)ret_var.inner;
10364         if (ret_var.is_owned) {
10365                 ret_ref |= 1;
10366         }
10367         return ret_ref;
10368 }
10369
10370 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) {
10371         LDKSecretKey funding_key_ref;
10372         CHECK(*((uint32_t*)funding_key) == 32);
10373         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
10374         LDKSecretKey revocation_base_key_ref;
10375         CHECK(*((uint32_t*)revocation_base_key) == 32);
10376         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
10377         LDKSecretKey payment_key_ref;
10378         CHECK(*((uint32_t*)payment_key) == 32);
10379         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
10380         LDKSecretKey delayed_payment_base_key_ref;
10381         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
10382         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
10383         LDKSecretKey htlc_base_key_ref;
10384         CHECK(*((uint32_t*)htlc_base_key) == 32);
10385         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
10386         LDKThirtyTwoBytes commitment_seed_ref;
10387         CHECK(*((uint32_t*)commitment_seed) == 32);
10388         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
10389         LDKThirtyTwoBytes channel_keys_id_ref;
10390         CHECK(*((uint32_t*)channel_keys_id) == 32);
10391         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
10392         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);
10393         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10394         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10395         long ret_ref = (long)ret_var.inner;
10396         if (ret_var.is_owned) {
10397                 ret_ref |= 1;
10398         }
10399         return ret_ref;
10400 }
10401
10402 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
10403         LDKInMemorySigner this_arg_conv;
10404         this_arg_conv.inner = (void*)(this_arg & (~1));
10405         this_arg_conv.is_owned = false;
10406         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
10407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10409         long ret_ref = (long)ret_var.inner;
10410         if (ret_var.is_owned) {
10411                 ret_ref |= 1;
10412         }
10413         return ret_ref;
10414 }
10415
10416 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
10417         LDKInMemorySigner this_arg_conv;
10418         this_arg_conv.inner = (void*)(this_arg & (~1));
10419         this_arg_conv.is_owned = false;
10420         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
10421         return ret_val;
10422 }
10423
10424 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
10425         LDKInMemorySigner this_arg_conv;
10426         this_arg_conv.inner = (void*)(this_arg & (~1));
10427         this_arg_conv.is_owned = false;
10428         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
10429         return ret_val;
10430 }
10431
10432 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
10433         LDKInMemorySigner this_arg_conv;
10434         this_arg_conv.inner = (void*)(this_arg & (~1));
10435         this_arg_conv.is_owned = false;
10436         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
10437         return ret_val;
10438 }
10439
10440 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
10441         LDKInMemorySigner this_arg_conv;
10442         this_arg_conv.inner = (void*)(this_arg & (~1));
10443         this_arg_conv.is_owned = false;
10444         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
10445         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10446         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10447         long ret_ref = (long)ret_var.inner;
10448         if (ret_var.is_owned) {
10449                 ret_ref |= 1;
10450         }
10451         return ret_ref;
10452 }
10453
10454 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(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         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
10459         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10460         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10461         long ret_ref = (long)ret_var.inner;
10462         if (ret_var.is_owned) {
10463                 ret_ref |= 1;
10464         }
10465         return ret_ref;
10466 }
10467
10468 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) {
10469         LDKInMemorySigner this_arg_conv;
10470         this_arg_conv.inner = (void*)(this_arg & (~1));
10471         this_arg_conv.is_owned = false;
10472         LDKTransaction spend_tx_ref;
10473         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10474         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10475         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10476         spend_tx_ref.data_is_owned = true;
10477         LDKStaticPaymentOutputDescriptor descriptor_conv;
10478         descriptor_conv.inner = (void*)(descriptor & (~1));
10479         descriptor_conv.is_owned = false;
10480         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10481         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10482         return (long)ret_conv;
10483 }
10484
10485 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) {
10486         LDKInMemorySigner this_arg_conv;
10487         this_arg_conv.inner = (void*)(this_arg & (~1));
10488         this_arg_conv.is_owned = false;
10489         LDKTransaction spend_tx_ref;
10490         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
10491         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
10492         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
10493         spend_tx_ref.data_is_owned = true;
10494         LDKDelayedPaymentOutputDescriptor descriptor_conv;
10495         descriptor_conv.inner = (void*)(descriptor & (~1));
10496         descriptor_conv.is_owned = false;
10497         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10498         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
10499         return (long)ret_conv;
10500 }
10501
10502 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
10503         LDKInMemorySigner this_arg_conv;
10504         this_arg_conv.inner = (void*)(this_arg & (~1));
10505         this_arg_conv.is_owned = false;
10506         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
10507         *ret = InMemorySigner_as_Sign(&this_arg_conv);
10508         return (long)ret;
10509 }
10510
10511 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
10512         LDKInMemorySigner obj_conv;
10513         obj_conv.inner = (void*)(obj & (~1));
10514         obj_conv.is_owned = false;
10515         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
10516         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10517         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
10518         CVec_u8Z_free(ret_var);
10519         return ret_arr;
10520 }
10521
10522 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
10523         LDKu8slice ser_ref;
10524         ser_ref.datalen = *((uint32_t*)ser);
10525         ser_ref.data = (int8_t*)(ser + 4);
10526         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10527         *ret_conv = InMemorySigner_read(ser_ref);
10528         return (long)ret_conv;
10529 }
10530
10531 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
10532         LDKKeysManager this_obj_conv;
10533         this_obj_conv.inner = (void*)(this_obj & (~1));
10534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10535         KeysManager_free(this_obj_conv);
10536 }
10537
10538 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
10539         unsigned char seed_arr[32];
10540         CHECK(*((uint32_t*)seed) == 32);
10541         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
10542         unsigned char (*seed_ref)[32] = &seed_arr;
10543         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
10544         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10545         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10546         long ret_ref = (long)ret_var.inner;
10547         if (ret_var.is_owned) {
10548                 ret_ref |= 1;
10549         }
10550         return ret_ref;
10551 }
10552
10553 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
10554         LDKKeysManager this_arg_conv;
10555         this_arg_conv.inner = (void*)(this_arg & (~1));
10556         this_arg_conv.is_owned = false;
10557         unsigned char params_arr[32];
10558         CHECK(*((uint32_t*)params) == 32);
10559         memcpy(params_arr, (uint8_t*)(params + 4), 32);
10560         unsigned char (*params_ref)[32] = &params_arr;
10561         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
10562         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10563         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10564         long ret_ref = (long)ret_var.inner;
10565         if (ret_var.is_owned) {
10566                 ret_ref |= 1;
10567         }
10568         return ret_ref;
10569 }
10570
10571 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) {
10572         LDKKeysManager this_arg_conv;
10573         this_arg_conv.inner = (void*)(this_arg & (~1));
10574         this_arg_conv.is_owned = false;
10575         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
10576         descriptors_constr.datalen = *((uint32_t*)descriptors);
10577         if (descriptors_constr.datalen > 0)
10578                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10579         else
10580                 descriptors_constr.data = NULL;
10581         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
10582         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
10583                 uint32_t descriptors_conv_27 = descriptors_vals[b];
10584                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
10585                 FREE((void*)descriptors_conv_27);
10586                 descriptors_constr.data[b] = descriptors_conv_27_conv;
10587         }
10588         LDKCVec_TxOutZ outputs_constr;
10589         outputs_constr.datalen = *((uint32_t*)outputs);
10590         if (outputs_constr.datalen > 0)
10591                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10592         else
10593                 outputs_constr.data = NULL;
10594         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
10595         for (size_t h = 0; h < outputs_constr.datalen; h++) {
10596                 uint32_t outputs_conv_7 = outputs_vals[h];
10597                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
10598                 FREE((void*)outputs_conv_7);
10599                 outputs_constr.data[h] = outputs_conv_7_conv;
10600         }
10601         LDKCVec_u8Z change_destination_script_ref;
10602         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
10603         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
10604         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
10605         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10606         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
10607         return (long)ret_conv;
10608 }
10609
10610 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
10611         LDKKeysManager this_arg_conv;
10612         this_arg_conv.inner = (void*)(this_arg & (~1));
10613         this_arg_conv.is_owned = false;
10614         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
10615         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
10616         return (long)ret;
10617 }
10618
10619 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
10620         LDKChannelManager this_obj_conv;
10621         this_obj_conv.inner = (void*)(this_obj & (~1));
10622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10623         ChannelManager_free(this_obj_conv);
10624 }
10625
10626 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
10627         LDKChainParameters this_obj_conv;
10628         this_obj_conv.inner = (void*)(this_obj & (~1));
10629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10630         ChainParameters_free(this_obj_conv);
10631 }
10632
10633 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
10634         LDKChainParameters this_ptr_conv;
10635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10636         this_ptr_conv.is_owned = false;
10637         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
10638         return ret_conv;
10639 }
10640
10641 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
10642         LDKChainParameters this_ptr_conv;
10643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10644         this_ptr_conv.is_owned = false;
10645         LDKNetwork val_conv = LDKNetwork_from_js(val);
10646         ChainParameters_set_network(&this_ptr_conv, val_conv);
10647 }
10648
10649 int8_tArray  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_hash(uint32_t this_ptr) {
10650         LDKChainParameters this_ptr_conv;
10651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10652         this_ptr_conv.is_owned = false;
10653         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10654         memcpy((uint8_t*)(ret_arr + 4), *ChainParameters_get_latest_hash(&this_ptr_conv), 32);
10655         return ret_arr;
10656 }
10657
10658 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_hash(uint32_t this_ptr, int8_tArray val) {
10659         LDKChainParameters this_ptr_conv;
10660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10661         this_ptr_conv.is_owned = false;
10662         LDKThirtyTwoBytes val_ref;
10663         CHECK(*((uint32_t*)val) == 32);
10664         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10665         ChainParameters_set_latest_hash(&this_ptr_conv, val_ref);
10666 }
10667
10668 int64_t  __attribute__((visibility("default"))) TS_ChainParameters_get_latest_height(uint32_t this_ptr) {
10669         LDKChainParameters this_ptr_conv;
10670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10671         this_ptr_conv.is_owned = false;
10672         int64_t ret_val = ChainParameters_get_latest_height(&this_ptr_conv);
10673         return ret_val;
10674 }
10675
10676 void  __attribute__((visibility("default"))) TS_ChainParameters_set_latest_height(uint32_t this_ptr, int64_t val) {
10677         LDKChainParameters this_ptr_conv;
10678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10679         this_ptr_conv.is_owned = false;
10680         ChainParameters_set_latest_height(&this_ptr_conv, val);
10681 }
10682
10683 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, int8_tArray latest_hash_arg, int64_t latest_height_arg) {
10684         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
10685         LDKThirtyTwoBytes latest_hash_arg_ref;
10686         CHECK(*((uint32_t*)latest_hash_arg) == 32);
10687         memcpy(latest_hash_arg_ref.data, (uint8_t*)(latest_hash_arg + 4), 32);
10688         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, latest_hash_arg_ref, latest_height_arg);
10689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10691         long ret_ref = (long)ret_var.inner;
10692         if (ret_var.is_owned) {
10693                 ret_ref |= 1;
10694         }
10695         return ret_ref;
10696 }
10697
10698 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
10699         LDKChannelDetails this_obj_conv;
10700         this_obj_conv.inner = (void*)(this_obj & (~1));
10701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
10702         ChannelDetails_free(this_obj_conv);
10703 }
10704
10705 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
10706         LDKChannelDetails this_ptr_conv;
10707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10708         this_ptr_conv.is_owned = false;
10709         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10710         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
10711         return ret_arr;
10712 }
10713
10714 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10715         LDKChannelDetails this_ptr_conv;
10716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10717         this_ptr_conv.is_owned = false;
10718         LDKThirtyTwoBytes val_ref;
10719         CHECK(*((uint32_t*)val) == 32);
10720         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10721         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
10722 }
10723
10724 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
10725         LDKChannelDetails this_ptr_conv;
10726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10727         this_ptr_conv.is_owned = false;
10728         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10729         memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
10730         return ret_arr;
10731 }
10732
10733 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
10734         LDKChannelDetails this_ptr_conv;
10735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10736         this_ptr_conv.is_owned = false;
10737         LDKPublicKey val_ref;
10738         CHECK(*((uint32_t*)val) == 33);
10739         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10740         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
10741 }
10742
10743 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
10744         LDKChannelDetails this_ptr_conv;
10745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10746         this_ptr_conv.is_owned = false;
10747         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
10748         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10749         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10750         long ret_ref = (long)ret_var.inner;
10751         if (ret_var.is_owned) {
10752                 ret_ref |= 1;
10753         }
10754         return ret_ref;
10755 }
10756
10757 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
10758         LDKChannelDetails this_ptr_conv;
10759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10760         this_ptr_conv.is_owned = false;
10761         LDKInitFeatures val_conv;
10762         val_conv.inner = (void*)(val & (~1));
10763         val_conv.is_owned = (val & 1) || (val == 0);
10764         val_conv = InitFeatures_clone(&val_conv);
10765         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
10766 }
10767
10768 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
10769         LDKChannelDetails this_ptr_conv;
10770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10771         this_ptr_conv.is_owned = false;
10772         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
10773         return ret_val;
10774 }
10775
10776 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
10777         LDKChannelDetails this_ptr_conv;
10778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10779         this_ptr_conv.is_owned = false;
10780         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
10781 }
10782
10783 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
10784         LDKChannelDetails this_ptr_conv;
10785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10786         this_ptr_conv.is_owned = false;
10787         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
10788         return ret_val;
10789 }
10790
10791 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
10792         LDKChannelDetails this_ptr_conv;
10793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10794         this_ptr_conv.is_owned = false;
10795         ChannelDetails_set_user_id(&this_ptr_conv, val);
10796 }
10797
10798 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
10799         LDKChannelDetails this_ptr_conv;
10800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10801         this_ptr_conv.is_owned = false;
10802         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
10803         return ret_val;
10804 }
10805
10806 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
10807         LDKChannelDetails this_ptr_conv;
10808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10809         this_ptr_conv.is_owned = false;
10810         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
10811 }
10812
10813 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
10814         LDKChannelDetails this_ptr_conv;
10815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10816         this_ptr_conv.is_owned = false;
10817         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
10818         return ret_val;
10819 }
10820
10821 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
10822         LDKChannelDetails this_ptr_conv;
10823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10824         this_ptr_conv.is_owned = false;
10825         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
10826 }
10827
10828 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
10829         LDKChannelDetails this_ptr_conv;
10830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10831         this_ptr_conv.is_owned = false;
10832         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
10833         return ret_val;
10834 }
10835
10836 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
10837         LDKChannelDetails this_ptr_conv;
10838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10839         this_ptr_conv.is_owned = false;
10840         ChannelDetails_set_is_live(&this_ptr_conv, val);
10841 }
10842
10843 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
10844         LDKChannelDetails orig_conv;
10845         orig_conv.inner = (void*)(orig & (~1));
10846         orig_conv.is_owned = false;
10847         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
10848         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10849         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10850         long ret_ref = (long)ret_var.inner;
10851         if (ret_var.is_owned) {
10852                 ret_ref |= 1;
10853         }
10854         return ret_ref;
10855 }
10856
10857 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
10858         if ((this_ptr & 1) != 0) return;
10859         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
10860         FREE((void*)this_ptr);
10861         PaymentSendFailure_free(this_ptr_conv);
10862 }
10863
10864 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
10865         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
10866         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
10867         *ret_copy = PaymentSendFailure_clone(orig_conv);
10868         long ret_ref = (long)ret_copy;
10869         return ret_ref;
10870 }
10871
10872 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) {
10873         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
10874         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
10875         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
10876         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
10877         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
10878         LDKUserConfig config_conv;
10879         config_conv.inner = (void*)(config & (~1));
10880         config_conv.is_owned = (config & 1) || (config == 0);
10881         config_conv = UserConfig_clone(&config_conv);
10882         LDKChainParameters params_conv;
10883         params_conv.inner = (void*)(params & (~1));
10884         params_conv.is_owned = (params & 1) || (params == 0);
10885         // Warning: we need a move here but no clone is available for LDKChainParameters
10886         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
10887         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10888         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10889         long ret_ref = (long)ret_var.inner;
10890         if (ret_var.is_owned) {
10891                 ret_ref |= 1;
10892         }
10893         return ret_ref;
10894 }
10895
10896 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) {
10897         LDKChannelManager this_arg_conv;
10898         this_arg_conv.inner = (void*)(this_arg & (~1));
10899         this_arg_conv.is_owned = false;
10900         LDKPublicKey their_network_key_ref;
10901         CHECK(*((uint32_t*)their_network_key) == 33);
10902         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
10903         LDKUserConfig override_config_conv;
10904         override_config_conv.inner = (void*)(override_config & (~1));
10905         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
10906         override_config_conv = UserConfig_clone(&override_config_conv);
10907         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10908         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
10909         return (long)ret_conv;
10910 }
10911
10912 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
10913         LDKChannelManager this_arg_conv;
10914         this_arg_conv.inner = (void*)(this_arg & (~1));
10915         this_arg_conv.is_owned = false;
10916         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
10917         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10918         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10919         for (size_t q = 0; q < ret_var.datalen; q++) {
10920                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10921                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10922                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10923                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
10924                 if (ret_conv_16_var.is_owned) {
10925                         ret_conv_16_ref |= 1;
10926                 }
10927                 ret_arr_ptr[q] = ret_conv_16_ref;
10928         }
10929         FREE(ret_var.data);
10930         return ret_arr;
10931 }
10932
10933 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
10934         LDKChannelManager this_arg_conv;
10935         this_arg_conv.inner = (void*)(this_arg & (~1));
10936         this_arg_conv.is_owned = false;
10937         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
10938         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
10939         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
10940         for (size_t q = 0; q < ret_var.datalen; q++) {
10941                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10942                 CHECK((((long)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10943                 CHECK((((long)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10944                 long ret_conv_16_ref = (long)ret_conv_16_var.inner;
10945                 if (ret_conv_16_var.is_owned) {
10946                         ret_conv_16_ref |= 1;
10947                 }
10948                 ret_arr_ptr[q] = ret_conv_16_ref;
10949         }
10950         FREE(ret_var.data);
10951         return ret_arr;
10952 }
10953
10954 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
10955         LDKChannelManager this_arg_conv;
10956         this_arg_conv.inner = (void*)(this_arg & (~1));
10957         this_arg_conv.is_owned = false;
10958         unsigned char channel_id_arr[32];
10959         CHECK(*((uint32_t*)channel_id) == 32);
10960         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
10961         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
10962         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10963         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
10964         return (long)ret_conv;
10965 }
10966
10967 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
10968         LDKChannelManager this_arg_conv;
10969         this_arg_conv.inner = (void*)(this_arg & (~1));
10970         this_arg_conv.is_owned = false;
10971         unsigned char channel_id_arr[32];
10972         CHECK(*((uint32_t*)channel_id) == 32);
10973         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
10974         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
10975         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10976         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
10977         return (long)ret_conv;
10978 }
10979
10980 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
10981         LDKChannelManager this_arg_conv;
10982         this_arg_conv.inner = (void*)(this_arg & (~1));
10983         this_arg_conv.is_owned = false;
10984         ChannelManager_force_close_all_channels(&this_arg_conv);
10985 }
10986
10987 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
10988         LDKChannelManager this_arg_conv;
10989         this_arg_conv.inner = (void*)(this_arg & (~1));
10990         this_arg_conv.is_owned = false;
10991         LDKRoute route_conv;
10992         route_conv.inner = (void*)(route & (~1));
10993         route_conv.is_owned = false;
10994         LDKThirtyTwoBytes payment_hash_ref;
10995         CHECK(*((uint32_t*)payment_hash) == 32);
10996         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
10997         LDKThirtyTwoBytes payment_secret_ref;
10998         CHECK(*((uint32_t*)payment_secret) == 32);
10999         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11000         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11001         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
11002         return (long)ret_conv;
11003 }
11004
11005 void  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
11006         LDKChannelManager this_arg_conv;
11007         this_arg_conv.inner = (void*)(this_arg & (~1));
11008         this_arg_conv.is_owned = false;
11009         unsigned char temporary_channel_id_arr[32];
11010         CHECK(*((uint32_t*)temporary_channel_id) == 32);
11011         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
11012         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
11013         LDKOutPoint funding_txo_conv;
11014         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11015         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
11016         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
11017         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
11018 }
11019
11020 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
11021         LDKChannelManager this_arg_conv;
11022         this_arg_conv.inner = (void*)(this_arg & (~1));
11023         this_arg_conv.is_owned = false;
11024         LDKThreeBytes rgb_ref;
11025         CHECK(*((uint32_t*)rgb) == 3);
11026         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
11027         LDKThirtyTwoBytes alias_ref;
11028         CHECK(*((uint32_t*)alias) == 32);
11029         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
11030         LDKCVec_NetAddressZ addresses_constr;
11031         addresses_constr.datalen = *((uint32_t*)addresses);
11032         if (addresses_constr.datalen > 0)
11033                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11034         else
11035                 addresses_constr.data = NULL;
11036         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
11037         for (size_t m = 0; m < addresses_constr.datalen; m++) {
11038                 uint32_t addresses_conv_12 = addresses_vals[m];
11039                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
11040                 FREE((void*)addresses_conv_12);
11041                 addresses_constr.data[m] = addresses_conv_12_conv;
11042         }
11043         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
11044 }
11045
11046 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
11047         LDKChannelManager this_arg_conv;
11048         this_arg_conv.inner = (void*)(this_arg & (~1));
11049         this_arg_conv.is_owned = false;
11050         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
11051 }
11052
11053 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
11054         LDKChannelManager this_arg_conv;
11055         this_arg_conv.inner = (void*)(this_arg & (~1));
11056         this_arg_conv.is_owned = false;
11057         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
11058 }
11059
11060 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
11061         LDKChannelManager this_arg_conv;
11062         this_arg_conv.inner = (void*)(this_arg & (~1));
11063         this_arg_conv.is_owned = false;
11064         unsigned char payment_hash_arr[32];
11065         CHECK(*((uint32_t*)payment_hash) == 32);
11066         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
11067         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11068         LDKThirtyTwoBytes payment_secret_ref;
11069         CHECK(*((uint32_t*)payment_secret) == 32);
11070         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11071         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
11072         return ret_val;
11073 }
11074
11075 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
11076         LDKChannelManager this_arg_conv;
11077         this_arg_conv.inner = (void*)(this_arg & (~1));
11078         this_arg_conv.is_owned = false;
11079         LDKThirtyTwoBytes payment_preimage_ref;
11080         CHECK(*((uint32_t*)payment_preimage) == 32);
11081         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11082         LDKThirtyTwoBytes payment_secret_ref;
11083         CHECK(*((uint32_t*)payment_secret) == 32);
11084         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11085         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
11086         return ret_val;
11087 }
11088
11089 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
11090         LDKChannelManager this_arg_conv;
11091         this_arg_conv.inner = (void*)(this_arg & (~1));
11092         this_arg_conv.is_owned = false;
11093         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11094         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
11095         return ret_arr;
11096 }
11097
11098 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
11099         LDKChannelManager this_arg_conv;
11100         this_arg_conv.inner = (void*)(this_arg & (~1));
11101         this_arg_conv.is_owned = false;
11102         LDKOutPoint funding_txo_conv;
11103         funding_txo_conv.inner = (void*)(funding_txo & (~1));
11104         funding_txo_conv.is_owned = false;
11105         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
11106 }
11107
11108 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
11109         LDKChannelManager this_arg_conv;
11110         this_arg_conv.inner = (void*)(this_arg & (~1));
11111         this_arg_conv.is_owned = false;
11112         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
11113         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
11114         return (long)ret;
11115 }
11116
11117 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
11118         LDKChannelManager this_arg_conv;
11119         this_arg_conv.inner = (void*)(this_arg & (~1));
11120         this_arg_conv.is_owned = false;
11121         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11122         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
11123         return (long)ret;
11124 }
11125
11126 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
11127         LDKChannelManager this_arg_conv;
11128         this_arg_conv.inner = (void*)(this_arg & (~1));
11129         this_arg_conv.is_owned = false;
11130         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
11131         *ret = ChannelManager_as_Listen(&this_arg_conv);
11132         return (long)ret;
11133 }
11134
11135 void  __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
11136         LDKChannelManager this_arg_conv;
11137         this_arg_conv.inner = (void*)(this_arg & (~1));
11138         this_arg_conv.is_owned = false;
11139         unsigned char header_arr[80];
11140         CHECK(*((uint32_t*)header) == 80);
11141         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11142         unsigned char (*header_ref)[80] = &header_arr;
11143         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11144         txdata_constr.datalen = *((uint32_t*)txdata);
11145         if (txdata_constr.datalen > 0)
11146                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11147         else
11148                 txdata_constr.data = NULL;
11149         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
11150         for (size_t e = 0; e < txdata_constr.datalen; e++) {
11151                 uint32_t txdata_conv_30 = txdata_vals[e];
11152                 LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
11153                 FREE((void*)txdata_conv_30);
11154                 txdata_constr.data[e] = txdata_conv_30_conv;
11155         }
11156         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
11157 }
11158
11159 void  __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
11160         LDKChannelManager this_arg_conv;
11161         this_arg_conv.inner = (void*)(this_arg & (~1));
11162         this_arg_conv.is_owned = false;
11163         unsigned char header_arr[80];
11164         CHECK(*((uint32_t*)header) == 80);
11165         memcpy(header_arr, (uint8_t*)(header + 4), 80);
11166         unsigned char (*header_ref)[80] = &header_arr;
11167         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
11168 }
11169
11170 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
11171         LDKChannelManager this_arg_conv;
11172         this_arg_conv.inner = (void*)(this_arg & (~1));
11173         this_arg_conv.is_owned = false;
11174         ChannelManager_await_persistable_update(&this_arg_conv);
11175 }
11176
11177 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
11178         LDKChannelManager this_arg_conv;
11179         this_arg_conv.inner = (void*)(this_arg & (~1));
11180         this_arg_conv.is_owned = false;
11181         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11182         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
11183         return (long)ret;
11184 }
11185
11186 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
11187         LDKChannelManager obj_conv;
11188         obj_conv.inner = (void*)(obj & (~1));
11189         obj_conv.is_owned = false;
11190         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
11191         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
11192         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
11193         CVec_u8Z_free(ret_var);
11194         return ret_arr;
11195 }
11196
11197 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
11198         LDKChannelManagerReadArgs this_obj_conv;
11199         this_obj_conv.inner = (void*)(this_obj & (~1));
11200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11201         ChannelManagerReadArgs_free(this_obj_conv);
11202 }
11203
11204 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(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_keys_manager(&this_ptr_conv);
11209         return ret_ret;
11210 }
11211
11212 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(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         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
11217         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
11218 }
11219
11220 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(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_fee_estimator(&this_ptr_conv);
11225         return ret_ret;
11226 }
11227
11228 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(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         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
11233         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
11234 }
11235
11236 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(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         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
11241         return ret_ret;
11242 }
11243
11244 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
11245         LDKChannelManagerReadArgs this_ptr_conv;
11246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11247         this_ptr_conv.is_owned = false;
11248         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
11249         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
11250 }
11251
11252 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
11253         LDKChannelManagerReadArgs this_ptr_conv;
11254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11255         this_ptr_conv.is_owned = false;
11256         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
11257         return ret_ret;
11258 }
11259
11260 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
11261         LDKChannelManagerReadArgs this_ptr_conv;
11262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11263         this_ptr_conv.is_owned = false;
11264         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
11265         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
11266 }
11267
11268 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
11269         LDKChannelManagerReadArgs this_ptr_conv;
11270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11271         this_ptr_conv.is_owned = false;
11272         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
11273         return ret_ret;
11274 }
11275
11276 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
11277         LDKChannelManagerReadArgs this_ptr_conv;
11278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11279         this_ptr_conv.is_owned = false;
11280         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
11281         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
11282 }
11283
11284 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
11285         LDKChannelManagerReadArgs this_ptr_conv;
11286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11287         this_ptr_conv.is_owned = false;
11288         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
11289         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11290         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11291         long ret_ref = (long)ret_var.inner;
11292         if (ret_var.is_owned) {
11293                 ret_ref |= 1;
11294         }
11295         return ret_ref;
11296 }
11297
11298 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
11299         LDKChannelManagerReadArgs this_ptr_conv;
11300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11301         this_ptr_conv.is_owned = false;
11302         LDKUserConfig val_conv;
11303         val_conv.inner = (void*)(val & (~1));
11304         val_conv.is_owned = (val & 1) || (val == 0);
11305         val_conv = UserConfig_clone(&val_conv);
11306         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
11307 }
11308
11309 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) {
11310         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
11311         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
11312         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
11313         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
11314         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
11315         LDKUserConfig default_config_conv;
11316         default_config_conv.inner = (void*)(default_config & (~1));
11317         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
11318         default_config_conv = UserConfig_clone(&default_config_conv);
11319         LDKCVec_ChannelMonitorZ channel_monitors_constr;
11320         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
11321         if (channel_monitors_constr.datalen > 0)
11322                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11323         else
11324                 channel_monitors_constr.data = NULL;
11325         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
11326         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
11327                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
11328                 LDKChannelMonitor channel_monitors_conv_16_conv;
11329                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
11330                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
11331                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
11332         }
11333         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);
11334         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11335         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11336         long ret_ref = (long)ret_var.inner;
11337         if (ret_var.is_owned) {
11338                 ret_ref |= 1;
11339         }
11340         return ret_ref;
11341 }
11342
11343 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
11344         LDKu8slice ser_ref;
11345         ser_ref.datalen = *((uint32_t*)ser);
11346         ser_ref.data = (int8_t*)(ser + 4);
11347         LDKChannelManagerReadArgs arg_conv;
11348         arg_conv.inner = (void*)(arg & (~1));
11349         arg_conv.is_owned = (arg & 1) || (arg == 0);
11350         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
11351         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11352         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
11353         return (long)ret_conv;
11354 }
11355
11356 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
11357         LDKDecodeError this_obj_conv;
11358         this_obj_conv.inner = (void*)(this_obj & (~1));
11359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11360         DecodeError_free(this_obj_conv);
11361 }
11362
11363 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
11364         LDKDecodeError orig_conv;
11365         orig_conv.inner = (void*)(orig & (~1));
11366         orig_conv.is_owned = false;
11367         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
11368         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11369         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11370         long ret_ref = (long)ret_var.inner;
11371         if (ret_var.is_owned) {
11372                 ret_ref |= 1;
11373         }
11374         return ret_ref;
11375 }
11376
11377 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
11378         LDKInit this_obj_conv;
11379         this_obj_conv.inner = (void*)(this_obj & (~1));
11380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11381         Init_free(this_obj_conv);
11382 }
11383
11384 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
11385         LDKInit this_ptr_conv;
11386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11387         this_ptr_conv.is_owned = false;
11388         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
11389         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11390         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11391         long ret_ref = (long)ret_var.inner;
11392         if (ret_var.is_owned) {
11393                 ret_ref |= 1;
11394         }
11395         return ret_ref;
11396 }
11397
11398 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
11399         LDKInit this_ptr_conv;
11400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11401         this_ptr_conv.is_owned = false;
11402         LDKInitFeatures val_conv;
11403         val_conv.inner = (void*)(val & (~1));
11404         val_conv.is_owned = (val & 1) || (val == 0);
11405         val_conv = InitFeatures_clone(&val_conv);
11406         Init_set_features(&this_ptr_conv, val_conv);
11407 }
11408
11409 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
11410         LDKInitFeatures features_arg_conv;
11411         features_arg_conv.inner = (void*)(features_arg & (~1));
11412         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
11413         features_arg_conv = InitFeatures_clone(&features_arg_conv);
11414         LDKInit ret_var = Init_new(features_arg_conv);
11415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11417         long ret_ref = (long)ret_var.inner;
11418         if (ret_var.is_owned) {
11419                 ret_ref |= 1;
11420         }
11421         return ret_ref;
11422 }
11423
11424 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
11425         LDKInit orig_conv;
11426         orig_conv.inner = (void*)(orig & (~1));
11427         orig_conv.is_owned = false;
11428         LDKInit ret_var = Init_clone(&orig_conv);
11429         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11430         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11431         long ret_ref = (long)ret_var.inner;
11432         if (ret_var.is_owned) {
11433                 ret_ref |= 1;
11434         }
11435         return ret_ref;
11436 }
11437
11438 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
11439         LDKErrorMessage this_obj_conv;
11440         this_obj_conv.inner = (void*)(this_obj & (~1));
11441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11442         ErrorMessage_free(this_obj_conv);
11443 }
11444
11445 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
11446         LDKErrorMessage this_ptr_conv;
11447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11448         this_ptr_conv.is_owned = false;
11449         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11450         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
11451         return ret_arr;
11452 }
11453
11454 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
11455         LDKErrorMessage this_ptr_conv;
11456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11457         this_ptr_conv.is_owned = false;
11458         LDKThirtyTwoBytes val_ref;
11459         CHECK(*((uint32_t*)val) == 32);
11460         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11461         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
11462 }
11463
11464 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
11465         LDKErrorMessage this_ptr_conv;
11466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11467         this_ptr_conv.is_owned = false;
11468         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
11469         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11470         return _conv;
11471 }
11472
11473 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
11474         LDKErrorMessage this_ptr_conv;
11475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11476         this_ptr_conv.is_owned = false;
11477         LDKCVec_u8Z val_ref;
11478         val_ref.datalen = *((uint32_t*)val);
11479         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11480         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11481         ErrorMessage_set_data(&this_ptr_conv, val_ref);
11482 }
11483
11484 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
11485         LDKThirtyTwoBytes channel_id_arg_ref;
11486         CHECK(*((uint32_t*)channel_id_arg) == 32);
11487         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
11488         LDKCVec_u8Z data_arg_ref;
11489         data_arg_ref.datalen = *((uint32_t*)data_arg);
11490         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11491         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
11492         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
11493         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11494         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11495         long ret_ref = (long)ret_var.inner;
11496         if (ret_var.is_owned) {
11497                 ret_ref |= 1;
11498         }
11499         return ret_ref;
11500 }
11501
11502 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
11503         LDKErrorMessage orig_conv;
11504         orig_conv.inner = (void*)(orig & (~1));
11505         orig_conv.is_owned = false;
11506         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
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 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
11517         LDKPing this_obj_conv;
11518         this_obj_conv.inner = (void*)(this_obj & (~1));
11519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11520         Ping_free(this_obj_conv);
11521 }
11522
11523 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
11524         LDKPing this_ptr_conv;
11525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11526         this_ptr_conv.is_owned = false;
11527         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
11528         return ret_val;
11529 }
11530
11531 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
11532         LDKPing this_ptr_conv;
11533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11534         this_ptr_conv.is_owned = false;
11535         Ping_set_ponglen(&this_ptr_conv, val);
11536 }
11537
11538 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
11539         LDKPing this_ptr_conv;
11540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11541         this_ptr_conv.is_owned = false;
11542         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
11543         return ret_val;
11544 }
11545
11546 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
11547         LDKPing this_ptr_conv;
11548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11549         this_ptr_conv.is_owned = false;
11550         Ping_set_byteslen(&this_ptr_conv, val);
11551 }
11552
11553 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
11554         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
11555         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11556         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11557         long ret_ref = (long)ret_var.inner;
11558         if (ret_var.is_owned) {
11559                 ret_ref |= 1;
11560         }
11561         return ret_ref;
11562 }
11563
11564 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
11565         LDKPing orig_conv;
11566         orig_conv.inner = (void*)(orig & (~1));
11567         orig_conv.is_owned = false;
11568         LDKPing ret_var = Ping_clone(&orig_conv);
11569         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11570         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11571         long ret_ref = (long)ret_var.inner;
11572         if (ret_var.is_owned) {
11573                 ret_ref |= 1;
11574         }
11575         return ret_ref;
11576 }
11577
11578 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
11579         LDKPong this_obj_conv;
11580         this_obj_conv.inner = (void*)(this_obj & (~1));
11581         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11582         Pong_free(this_obj_conv);
11583 }
11584
11585 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
11586         LDKPong this_ptr_conv;
11587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11588         this_ptr_conv.is_owned = false;
11589         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
11590         return ret_val;
11591 }
11592
11593 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
11594         LDKPong this_ptr_conv;
11595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11596         this_ptr_conv.is_owned = false;
11597         Pong_set_byteslen(&this_ptr_conv, val);
11598 }
11599
11600 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
11601         LDKPong ret_var = Pong_new(byteslen_arg);
11602         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11603         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11604         long ret_ref = (long)ret_var.inner;
11605         if (ret_var.is_owned) {
11606                 ret_ref |= 1;
11607         }
11608         return ret_ref;
11609 }
11610
11611 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
11612         LDKPong orig_conv;
11613         orig_conv.inner = (void*)(orig & (~1));
11614         orig_conv.is_owned = false;
11615         LDKPong ret_var = Pong_clone(&orig_conv);
11616         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11617         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11618         long ret_ref = (long)ret_var.inner;
11619         if (ret_var.is_owned) {
11620                 ret_ref |= 1;
11621         }
11622         return ret_ref;
11623 }
11624
11625 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
11626         LDKOpenChannel this_obj_conv;
11627         this_obj_conv.inner = (void*)(this_obj & (~1));
11628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11629         OpenChannel_free(this_obj_conv);
11630 }
11631
11632 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
11633         LDKOpenChannel this_ptr_conv;
11634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11635         this_ptr_conv.is_owned = false;
11636         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11637         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
11638         return ret_arr;
11639 }
11640
11641 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11642         LDKOpenChannel this_ptr_conv;
11643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11644         this_ptr_conv.is_owned = false;
11645         LDKThirtyTwoBytes val_ref;
11646         CHECK(*((uint32_t*)val) == 32);
11647         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11648         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
11649 }
11650
11651 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
11652         LDKOpenChannel this_ptr_conv;
11653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11654         this_ptr_conv.is_owned = false;
11655         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11656         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
11657         return ret_arr;
11658 }
11659
11660 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
11661         LDKOpenChannel this_ptr_conv;
11662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11663         this_ptr_conv.is_owned = false;
11664         LDKThirtyTwoBytes val_ref;
11665         CHECK(*((uint32_t*)val) == 32);
11666         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11667         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
11668 }
11669
11670 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
11671         LDKOpenChannel this_ptr_conv;
11672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11673         this_ptr_conv.is_owned = false;
11674         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
11675         return ret_val;
11676 }
11677
11678 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
11679         LDKOpenChannel this_ptr_conv;
11680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11681         this_ptr_conv.is_owned = false;
11682         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
11683 }
11684
11685 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
11686         LDKOpenChannel this_ptr_conv;
11687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11688         this_ptr_conv.is_owned = false;
11689         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
11690         return ret_val;
11691 }
11692
11693 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
11694         LDKOpenChannel this_ptr_conv;
11695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11696         this_ptr_conv.is_owned = false;
11697         OpenChannel_set_push_msat(&this_ptr_conv, val);
11698 }
11699
11700 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
11701         LDKOpenChannel this_ptr_conv;
11702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11703         this_ptr_conv.is_owned = false;
11704         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
11705         return ret_val;
11706 }
11707
11708 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
11709         LDKOpenChannel this_ptr_conv;
11710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11711         this_ptr_conv.is_owned = false;
11712         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
11713 }
11714
11715 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
11716         LDKOpenChannel this_ptr_conv;
11717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11718         this_ptr_conv.is_owned = false;
11719         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
11720         return ret_val;
11721 }
11722
11723 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
11724         LDKOpenChannel this_ptr_conv;
11725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11726         this_ptr_conv.is_owned = false;
11727         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
11728 }
11729
11730 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
11731         LDKOpenChannel this_ptr_conv;
11732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11733         this_ptr_conv.is_owned = false;
11734         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
11735         return ret_val;
11736 }
11737
11738 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
11739         LDKOpenChannel this_ptr_conv;
11740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11741         this_ptr_conv.is_owned = false;
11742         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
11743 }
11744
11745 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
11746         LDKOpenChannel this_ptr_conv;
11747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11748         this_ptr_conv.is_owned = false;
11749         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
11750         return ret_val;
11751 }
11752
11753 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11754         LDKOpenChannel this_ptr_conv;
11755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11756         this_ptr_conv.is_owned = false;
11757         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
11758 }
11759
11760 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
11761         LDKOpenChannel this_ptr_conv;
11762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11763         this_ptr_conv.is_owned = false;
11764         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
11765         return ret_val;
11766 }
11767
11768 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
11769         LDKOpenChannel this_ptr_conv;
11770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11771         this_ptr_conv.is_owned = false;
11772         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
11773 }
11774
11775 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
11776         LDKOpenChannel this_ptr_conv;
11777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11778         this_ptr_conv.is_owned = false;
11779         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
11780         return ret_val;
11781 }
11782
11783 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
11784         LDKOpenChannel this_ptr_conv;
11785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11786         this_ptr_conv.is_owned = false;
11787         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
11788 }
11789
11790 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
11791         LDKOpenChannel this_ptr_conv;
11792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11793         this_ptr_conv.is_owned = false;
11794         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
11795         return ret_val;
11796 }
11797
11798 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
11799         LDKOpenChannel this_ptr_conv;
11800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11801         this_ptr_conv.is_owned = false;
11802         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
11803 }
11804
11805 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
11806         LDKOpenChannel this_ptr_conv;
11807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11808         this_ptr_conv.is_owned = false;
11809         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11810         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
11811         return ret_arr;
11812 }
11813
11814 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
11815         LDKOpenChannel this_ptr_conv;
11816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11817         this_ptr_conv.is_owned = false;
11818         LDKPublicKey val_ref;
11819         CHECK(*((uint32_t*)val) == 33);
11820         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11821         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
11822 }
11823
11824 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
11825         LDKOpenChannel this_ptr_conv;
11826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11827         this_ptr_conv.is_owned = false;
11828         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11829         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
11830         return ret_arr;
11831 }
11832
11833 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
11834         LDKOpenChannel this_ptr_conv;
11835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11836         this_ptr_conv.is_owned = false;
11837         LDKPublicKey val_ref;
11838         CHECK(*((uint32_t*)val) == 33);
11839         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11840         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
11841 }
11842
11843 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
11844         LDKOpenChannel this_ptr_conv;
11845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11846         this_ptr_conv.is_owned = false;
11847         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11848         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
11849         return ret_arr;
11850 }
11851
11852 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
11853         LDKOpenChannel this_ptr_conv;
11854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11855         this_ptr_conv.is_owned = false;
11856         LDKPublicKey val_ref;
11857         CHECK(*((uint32_t*)val) == 33);
11858         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11859         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
11860 }
11861
11862 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
11863         LDKOpenChannel this_ptr_conv;
11864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11865         this_ptr_conv.is_owned = false;
11866         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11867         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
11868         return ret_arr;
11869 }
11870
11871 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
11872         LDKOpenChannel this_ptr_conv;
11873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11874         this_ptr_conv.is_owned = false;
11875         LDKPublicKey val_ref;
11876         CHECK(*((uint32_t*)val) == 33);
11877         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11878         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11879 }
11880
11881 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
11882         LDKOpenChannel this_ptr_conv;
11883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11884         this_ptr_conv.is_owned = false;
11885         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11886         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
11887         return ret_arr;
11888 }
11889
11890 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
11891         LDKOpenChannel this_ptr_conv;
11892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11893         this_ptr_conv.is_owned = false;
11894         LDKPublicKey val_ref;
11895         CHECK(*((uint32_t*)val) == 33);
11896         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11897         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
11898 }
11899
11900 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
11901         LDKOpenChannel this_ptr_conv;
11902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11903         this_ptr_conv.is_owned = false;
11904         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
11905         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
11906         return ret_arr;
11907 }
11908
11909 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
11910         LDKOpenChannel this_ptr_conv;
11911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11912         this_ptr_conv.is_owned = false;
11913         LDKPublicKey val_ref;
11914         CHECK(*((uint32_t*)val) == 33);
11915         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
11916         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
11917 }
11918
11919 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
11920         LDKOpenChannel this_ptr_conv;
11921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11922         this_ptr_conv.is_owned = false;
11923         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
11924         return ret_val;
11925 }
11926
11927 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
11928         LDKOpenChannel this_ptr_conv;
11929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11930         this_ptr_conv.is_owned = false;
11931         OpenChannel_set_channel_flags(&this_ptr_conv, val);
11932 }
11933
11934 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
11935         LDKOpenChannel orig_conv;
11936         orig_conv.inner = (void*)(orig & (~1));
11937         orig_conv.is_owned = false;
11938         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
11939         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11940         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11941         long ret_ref = (long)ret_var.inner;
11942         if (ret_var.is_owned) {
11943                 ret_ref |= 1;
11944         }
11945         return ret_ref;
11946 }
11947
11948 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
11949         LDKAcceptChannel this_obj_conv;
11950         this_obj_conv.inner = (void*)(this_obj & (~1));
11951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
11952         AcceptChannel_free(this_obj_conv);
11953 }
11954
11955 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
11956         LDKAcceptChannel this_ptr_conv;
11957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11958         this_ptr_conv.is_owned = false;
11959         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11960         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
11961         return ret_arr;
11962 }
11963
11964 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
11965         LDKAcceptChannel this_ptr_conv;
11966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11967         this_ptr_conv.is_owned = false;
11968         LDKThirtyTwoBytes val_ref;
11969         CHECK(*((uint32_t*)val) == 32);
11970         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11971         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
11972 }
11973
11974 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
11975         LDKAcceptChannel this_ptr_conv;
11976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11977         this_ptr_conv.is_owned = false;
11978         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
11979         return ret_val;
11980 }
11981
11982 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
11983         LDKAcceptChannel this_ptr_conv;
11984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11985         this_ptr_conv.is_owned = false;
11986         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
11987 }
11988
11989 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
11990         LDKAcceptChannel this_ptr_conv;
11991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11992         this_ptr_conv.is_owned = false;
11993         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
11994         return ret_val;
11995 }
11996
11997 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
11998         LDKAcceptChannel this_ptr_conv;
11999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12000         this_ptr_conv.is_owned = false;
12001         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12002 }
12003
12004 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
12005         LDKAcceptChannel this_ptr_conv;
12006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12007         this_ptr_conv.is_owned = false;
12008         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
12009         return ret_val;
12010 }
12011
12012 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12013         LDKAcceptChannel this_ptr_conv;
12014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12015         this_ptr_conv.is_owned = false;
12016         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
12017 }
12018
12019 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
12020         LDKAcceptChannel this_ptr_conv;
12021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12022         this_ptr_conv.is_owned = false;
12023         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
12024         return ret_val;
12025 }
12026
12027 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12028         LDKAcceptChannel this_ptr_conv;
12029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12030         this_ptr_conv.is_owned = false;
12031         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
12032 }
12033
12034 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
12035         LDKAcceptChannel this_ptr_conv;
12036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12037         this_ptr_conv.is_owned = false;
12038         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
12039         return ret_val;
12040 }
12041
12042 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
12043         LDKAcceptChannel this_ptr_conv;
12044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12045         this_ptr_conv.is_owned = false;
12046         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
12047 }
12048
12049 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
12050         LDKAcceptChannel this_ptr_conv;
12051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12052         this_ptr_conv.is_owned = false;
12053         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
12054         return ret_val;
12055 }
12056
12057 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
12058         LDKAcceptChannel this_ptr_conv;
12059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12060         this_ptr_conv.is_owned = false;
12061         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
12062 }
12063
12064 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
12065         LDKAcceptChannel this_ptr_conv;
12066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12067         this_ptr_conv.is_owned = false;
12068         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
12069         return ret_val;
12070 }
12071
12072 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12073         LDKAcceptChannel this_ptr_conv;
12074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12075         this_ptr_conv.is_owned = false;
12076         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
12077 }
12078
12079 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
12080         LDKAcceptChannel this_ptr_conv;
12081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12082         this_ptr_conv.is_owned = false;
12083         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12084         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12085         return ret_arr;
12086 }
12087
12088 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
12089         LDKAcceptChannel this_ptr_conv;
12090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12091         this_ptr_conv.is_owned = false;
12092         LDKPublicKey val_ref;
12093         CHECK(*((uint32_t*)val) == 33);
12094         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12095         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
12096 }
12097
12098 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
12099         LDKAcceptChannel this_ptr_conv;
12100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12101         this_ptr_conv.is_owned = false;
12102         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12103         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12104         return ret_arr;
12105 }
12106
12107 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
12108         LDKAcceptChannel this_ptr_conv;
12109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12110         this_ptr_conv.is_owned = false;
12111         LDKPublicKey val_ref;
12112         CHECK(*((uint32_t*)val) == 33);
12113         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12114         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
12115 }
12116
12117 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
12118         LDKAcceptChannel this_ptr_conv;
12119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12120         this_ptr_conv.is_owned = false;
12121         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12122         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
12123         return ret_arr;
12124 }
12125
12126 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
12127         LDKAcceptChannel this_ptr_conv;
12128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12129         this_ptr_conv.is_owned = false;
12130         LDKPublicKey val_ref;
12131         CHECK(*((uint32_t*)val) == 33);
12132         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12133         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
12134 }
12135
12136 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
12137         LDKAcceptChannel this_ptr_conv;
12138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12139         this_ptr_conv.is_owned = false;
12140         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12141         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12142         return ret_arr;
12143 }
12144
12145 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
12146         LDKAcceptChannel this_ptr_conv;
12147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12148         this_ptr_conv.is_owned = false;
12149         LDKPublicKey val_ref;
12150         CHECK(*((uint32_t*)val) == 33);
12151         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12152         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12153 }
12154
12155 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
12156         LDKAcceptChannel this_ptr_conv;
12157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12158         this_ptr_conv.is_owned = false;
12159         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12160         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12161         return ret_arr;
12162 }
12163
12164 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
12165         LDKAcceptChannel this_ptr_conv;
12166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12167         this_ptr_conv.is_owned = false;
12168         LDKPublicKey val_ref;
12169         CHECK(*((uint32_t*)val) == 33);
12170         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12171         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
12172 }
12173
12174 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
12175         LDKAcceptChannel this_ptr_conv;
12176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12177         this_ptr_conv.is_owned = false;
12178         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12179         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12180         return ret_arr;
12181 }
12182
12183 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12184         LDKAcceptChannel this_ptr_conv;
12185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12186         this_ptr_conv.is_owned = false;
12187         LDKPublicKey val_ref;
12188         CHECK(*((uint32_t*)val) == 33);
12189         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12190         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
12191 }
12192
12193 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
12194         LDKAcceptChannel orig_conv;
12195         orig_conv.inner = (void*)(orig & (~1));
12196         orig_conv.is_owned = false;
12197         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
12198         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12199         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12200         long ret_ref = (long)ret_var.inner;
12201         if (ret_var.is_owned) {
12202                 ret_ref |= 1;
12203         }
12204         return ret_ref;
12205 }
12206
12207 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
12208         LDKFundingCreated this_obj_conv;
12209         this_obj_conv.inner = (void*)(this_obj & (~1));
12210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12211         FundingCreated_free(this_obj_conv);
12212 }
12213
12214 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
12215         LDKFundingCreated this_ptr_conv;
12216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12217         this_ptr_conv.is_owned = false;
12218         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12219         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
12220         return ret_arr;
12221 }
12222
12223 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
12224         LDKFundingCreated this_ptr_conv;
12225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12226         this_ptr_conv.is_owned = false;
12227         LDKThirtyTwoBytes val_ref;
12228         CHECK(*((uint32_t*)val) == 32);
12229         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12230         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
12231 }
12232
12233 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
12234         LDKFundingCreated this_ptr_conv;
12235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12236         this_ptr_conv.is_owned = false;
12237         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12238         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
12239         return ret_arr;
12240 }
12241
12242 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
12243         LDKFundingCreated this_ptr_conv;
12244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12245         this_ptr_conv.is_owned = false;
12246         LDKThirtyTwoBytes val_ref;
12247         CHECK(*((uint32_t*)val) == 32);
12248         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12249         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
12250 }
12251
12252 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
12253         LDKFundingCreated this_ptr_conv;
12254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12255         this_ptr_conv.is_owned = false;
12256         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
12257         return ret_val;
12258 }
12259
12260 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
12261         LDKFundingCreated this_ptr_conv;
12262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12263         this_ptr_conv.is_owned = false;
12264         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
12265 }
12266
12267 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
12268         LDKFundingCreated this_ptr_conv;
12269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12270         this_ptr_conv.is_owned = false;
12271         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12272         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
12273         return ret_arr;
12274 }
12275
12276 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
12277         LDKFundingCreated this_ptr_conv;
12278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12279         this_ptr_conv.is_owned = false;
12280         LDKSignature val_ref;
12281         CHECK(*((uint32_t*)val) == 64);
12282         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12283         FundingCreated_set_signature(&this_ptr_conv, val_ref);
12284 }
12285
12286 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) {
12287         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
12288         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
12289         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
12290         LDKThirtyTwoBytes funding_txid_arg_ref;
12291         CHECK(*((uint32_t*)funding_txid_arg) == 32);
12292         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
12293         LDKSignature signature_arg_ref;
12294         CHECK(*((uint32_t*)signature_arg) == 64);
12295         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12296         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
12297         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12298         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12299         long ret_ref = (long)ret_var.inner;
12300         if (ret_var.is_owned) {
12301                 ret_ref |= 1;
12302         }
12303         return ret_ref;
12304 }
12305
12306 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
12307         LDKFundingCreated orig_conv;
12308         orig_conv.inner = (void*)(orig & (~1));
12309         orig_conv.is_owned = false;
12310         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
12311         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12312         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12313         long ret_ref = (long)ret_var.inner;
12314         if (ret_var.is_owned) {
12315                 ret_ref |= 1;
12316         }
12317         return ret_ref;
12318 }
12319
12320 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
12321         LDKFundingSigned this_obj_conv;
12322         this_obj_conv.inner = (void*)(this_obj & (~1));
12323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12324         FundingSigned_free(this_obj_conv);
12325 }
12326
12327 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
12328         LDKFundingSigned this_ptr_conv;
12329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12330         this_ptr_conv.is_owned = false;
12331         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12332         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
12333         return ret_arr;
12334 }
12335
12336 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12337         LDKFundingSigned this_ptr_conv;
12338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12339         this_ptr_conv.is_owned = false;
12340         LDKThirtyTwoBytes val_ref;
12341         CHECK(*((uint32_t*)val) == 32);
12342         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12343         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
12344 }
12345
12346 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
12347         LDKFundingSigned this_ptr_conv;
12348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12349         this_ptr_conv.is_owned = false;
12350         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12351         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12352         return ret_arr;
12353 }
12354
12355 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12356         LDKFundingSigned this_ptr_conv;
12357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12358         this_ptr_conv.is_owned = false;
12359         LDKSignature val_ref;
12360         CHECK(*((uint32_t*)val) == 64);
12361         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12362         FundingSigned_set_signature(&this_ptr_conv, val_ref);
12363 }
12364
12365 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
12366         LDKThirtyTwoBytes channel_id_arg_ref;
12367         CHECK(*((uint32_t*)channel_id_arg) == 32);
12368         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12369         LDKSignature signature_arg_ref;
12370         CHECK(*((uint32_t*)signature_arg) == 64);
12371         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12372         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
12373         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12374         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12375         long ret_ref = (long)ret_var.inner;
12376         if (ret_var.is_owned) {
12377                 ret_ref |= 1;
12378         }
12379         return ret_ref;
12380 }
12381
12382 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
12383         LDKFundingSigned orig_conv;
12384         orig_conv.inner = (void*)(orig & (~1));
12385         orig_conv.is_owned = false;
12386         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
12387         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12388         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12389         long ret_ref = (long)ret_var.inner;
12390         if (ret_var.is_owned) {
12391                 ret_ref |= 1;
12392         }
12393         return ret_ref;
12394 }
12395
12396 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
12397         LDKFundingLocked this_obj_conv;
12398         this_obj_conv.inner = (void*)(this_obj & (~1));
12399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12400         FundingLocked_free(this_obj_conv);
12401 }
12402
12403 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
12404         LDKFundingLocked this_ptr_conv;
12405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12406         this_ptr_conv.is_owned = false;
12407         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12408         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
12409         return ret_arr;
12410 }
12411
12412 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12413         LDKFundingLocked this_ptr_conv;
12414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12415         this_ptr_conv.is_owned = false;
12416         LDKThirtyTwoBytes val_ref;
12417         CHECK(*((uint32_t*)val) == 32);
12418         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12419         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
12420 }
12421
12422 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
12423         LDKFundingLocked this_ptr_conv;
12424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12425         this_ptr_conv.is_owned = false;
12426         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12427         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12428         return ret_arr;
12429 }
12430
12431 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
12432         LDKFundingLocked this_ptr_conv;
12433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12434         this_ptr_conv.is_owned = false;
12435         LDKPublicKey val_ref;
12436         CHECK(*((uint32_t*)val) == 33);
12437         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
12438         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
12439 }
12440
12441 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
12442         LDKThirtyTwoBytes channel_id_arg_ref;
12443         CHECK(*((uint32_t*)channel_id_arg) == 32);
12444         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12445         LDKPublicKey next_per_commitment_point_arg_ref;
12446         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
12447         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
12448         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
12449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12451         long ret_ref = (long)ret_var.inner;
12452         if (ret_var.is_owned) {
12453                 ret_ref |= 1;
12454         }
12455         return ret_ref;
12456 }
12457
12458 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
12459         LDKFundingLocked orig_conv;
12460         orig_conv.inner = (void*)(orig & (~1));
12461         orig_conv.is_owned = false;
12462         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
12463         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12464         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12465         long ret_ref = (long)ret_var.inner;
12466         if (ret_var.is_owned) {
12467                 ret_ref |= 1;
12468         }
12469         return ret_ref;
12470 }
12471
12472 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
12473         LDKShutdown this_obj_conv;
12474         this_obj_conv.inner = (void*)(this_obj & (~1));
12475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12476         Shutdown_free(this_obj_conv);
12477 }
12478
12479 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
12480         LDKShutdown this_ptr_conv;
12481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12482         this_ptr_conv.is_owned = false;
12483         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12484         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
12485         return ret_arr;
12486 }
12487
12488 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12489         LDKShutdown this_ptr_conv;
12490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12491         this_ptr_conv.is_owned = false;
12492         LDKThirtyTwoBytes val_ref;
12493         CHECK(*((uint32_t*)val) == 32);
12494         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12495         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
12496 }
12497
12498 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
12499         LDKShutdown this_ptr_conv;
12500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12501         this_ptr_conv.is_owned = false;
12502         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
12503         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12504         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12505         return ret_arr;
12506 }
12507
12508 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
12509         LDKShutdown this_ptr_conv;
12510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12511         this_ptr_conv.is_owned = false;
12512         LDKCVec_u8Z val_ref;
12513         val_ref.datalen = *((uint32_t*)val);
12514         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
12515         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
12516         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
12517 }
12518
12519 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
12520         LDKThirtyTwoBytes channel_id_arg_ref;
12521         CHECK(*((uint32_t*)channel_id_arg) == 32);
12522         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12523         LDKCVec_u8Z scriptpubkey_arg_ref;
12524         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
12525         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
12526         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
12527         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
12528         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12529         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12530         long ret_ref = (long)ret_var.inner;
12531         if (ret_var.is_owned) {
12532                 ret_ref |= 1;
12533         }
12534         return ret_ref;
12535 }
12536
12537 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
12538         LDKShutdown orig_conv;
12539         orig_conv.inner = (void*)(orig & (~1));
12540         orig_conv.is_owned = false;
12541         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
12542         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12543         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12544         long ret_ref = (long)ret_var.inner;
12545         if (ret_var.is_owned) {
12546                 ret_ref |= 1;
12547         }
12548         return ret_ref;
12549 }
12550
12551 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
12552         LDKClosingSigned this_obj_conv;
12553         this_obj_conv.inner = (void*)(this_obj & (~1));
12554         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12555         ClosingSigned_free(this_obj_conv);
12556 }
12557
12558 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
12559         LDKClosingSigned this_ptr_conv;
12560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12561         this_ptr_conv.is_owned = false;
12562         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12563         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
12564         return ret_arr;
12565 }
12566
12567 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12568         LDKClosingSigned this_ptr_conv;
12569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12570         this_ptr_conv.is_owned = false;
12571         LDKThirtyTwoBytes val_ref;
12572         CHECK(*((uint32_t*)val) == 32);
12573         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12574         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
12575 }
12576
12577 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
12578         LDKClosingSigned this_ptr_conv;
12579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12580         this_ptr_conv.is_owned = false;
12581         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
12582         return ret_val;
12583 }
12584
12585 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
12586         LDKClosingSigned this_ptr_conv;
12587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12588         this_ptr_conv.is_owned = false;
12589         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
12590 }
12591
12592 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
12593         LDKClosingSigned this_ptr_conv;
12594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12595         this_ptr_conv.is_owned = false;
12596         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12597         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
12598         return ret_arr;
12599 }
12600
12601 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12602         LDKClosingSigned this_ptr_conv;
12603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12604         this_ptr_conv.is_owned = false;
12605         LDKSignature val_ref;
12606         CHECK(*((uint32_t*)val) == 64);
12607         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
12608         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
12609 }
12610
12611 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
12612         LDKThirtyTwoBytes channel_id_arg_ref;
12613         CHECK(*((uint32_t*)channel_id_arg) == 32);
12614         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12615         LDKSignature signature_arg_ref;
12616         CHECK(*((uint32_t*)signature_arg) == 64);
12617         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
12618         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
12619         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12620         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12621         long ret_ref = (long)ret_var.inner;
12622         if (ret_var.is_owned) {
12623                 ret_ref |= 1;
12624         }
12625         return ret_ref;
12626 }
12627
12628 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
12629         LDKClosingSigned orig_conv;
12630         orig_conv.inner = (void*)(orig & (~1));
12631         orig_conv.is_owned = false;
12632         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
12633         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12634         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12635         long ret_ref = (long)ret_var.inner;
12636         if (ret_var.is_owned) {
12637                 ret_ref |= 1;
12638         }
12639         return ret_ref;
12640 }
12641
12642 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
12643         LDKUpdateAddHTLC this_obj_conv;
12644         this_obj_conv.inner = (void*)(this_obj & (~1));
12645         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12646         UpdateAddHTLC_free(this_obj_conv);
12647 }
12648
12649 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
12650         LDKUpdateAddHTLC this_ptr_conv;
12651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12652         this_ptr_conv.is_owned = false;
12653         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12654         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
12655         return ret_arr;
12656 }
12657
12658 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12659         LDKUpdateAddHTLC this_ptr_conv;
12660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12661         this_ptr_conv.is_owned = false;
12662         LDKThirtyTwoBytes val_ref;
12663         CHECK(*((uint32_t*)val) == 32);
12664         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12665         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
12666 }
12667
12668 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
12669         LDKUpdateAddHTLC this_ptr_conv;
12670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12671         this_ptr_conv.is_owned = false;
12672         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
12673         return ret_val;
12674 }
12675
12676 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12677         LDKUpdateAddHTLC this_ptr_conv;
12678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12679         this_ptr_conv.is_owned = false;
12680         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
12681 }
12682
12683 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
12684         LDKUpdateAddHTLC this_ptr_conv;
12685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12686         this_ptr_conv.is_owned = false;
12687         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
12688         return ret_val;
12689 }
12690
12691 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
12692         LDKUpdateAddHTLC this_ptr_conv;
12693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12694         this_ptr_conv.is_owned = false;
12695         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
12696 }
12697
12698 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
12699         LDKUpdateAddHTLC this_ptr_conv;
12700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12701         this_ptr_conv.is_owned = false;
12702         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12703         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
12704         return ret_arr;
12705 }
12706
12707 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
12708         LDKUpdateAddHTLC this_ptr_conv;
12709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12710         this_ptr_conv.is_owned = false;
12711         LDKThirtyTwoBytes val_ref;
12712         CHECK(*((uint32_t*)val) == 32);
12713         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12714         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
12715 }
12716
12717 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
12718         LDKUpdateAddHTLC this_ptr_conv;
12719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12720         this_ptr_conv.is_owned = false;
12721         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
12722         return ret_val;
12723 }
12724
12725 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
12726         LDKUpdateAddHTLC this_ptr_conv;
12727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12728         this_ptr_conv.is_owned = false;
12729         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
12730 }
12731
12732 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
12733         LDKUpdateAddHTLC orig_conv;
12734         orig_conv.inner = (void*)(orig & (~1));
12735         orig_conv.is_owned = false;
12736         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
12737         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12738         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12739         long ret_ref = (long)ret_var.inner;
12740         if (ret_var.is_owned) {
12741                 ret_ref |= 1;
12742         }
12743         return ret_ref;
12744 }
12745
12746 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
12747         LDKUpdateFulfillHTLC this_obj_conv;
12748         this_obj_conv.inner = (void*)(this_obj & (~1));
12749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12750         UpdateFulfillHTLC_free(this_obj_conv);
12751 }
12752
12753 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
12754         LDKUpdateFulfillHTLC this_ptr_conv;
12755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12756         this_ptr_conv.is_owned = false;
12757         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12758         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
12759         return ret_arr;
12760 }
12761
12762 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12763         LDKUpdateFulfillHTLC this_ptr_conv;
12764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12765         this_ptr_conv.is_owned = false;
12766         LDKThirtyTwoBytes val_ref;
12767         CHECK(*((uint32_t*)val) == 32);
12768         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12769         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
12770 }
12771
12772 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
12773         LDKUpdateFulfillHTLC this_ptr_conv;
12774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12775         this_ptr_conv.is_owned = false;
12776         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
12777         return ret_val;
12778 }
12779
12780 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12781         LDKUpdateFulfillHTLC this_ptr_conv;
12782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12783         this_ptr_conv.is_owned = false;
12784         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
12785 }
12786
12787 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
12788         LDKUpdateFulfillHTLC this_ptr_conv;
12789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12790         this_ptr_conv.is_owned = false;
12791         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12792         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
12793         return ret_arr;
12794 }
12795
12796 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
12797         LDKUpdateFulfillHTLC this_ptr_conv;
12798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12799         this_ptr_conv.is_owned = false;
12800         LDKThirtyTwoBytes val_ref;
12801         CHECK(*((uint32_t*)val) == 32);
12802         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12803         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
12804 }
12805
12806 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
12807         LDKThirtyTwoBytes channel_id_arg_ref;
12808         CHECK(*((uint32_t*)channel_id_arg) == 32);
12809         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
12810         LDKThirtyTwoBytes payment_preimage_arg_ref;
12811         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
12812         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
12813         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
12814         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12815         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12816         long ret_ref = (long)ret_var.inner;
12817         if (ret_var.is_owned) {
12818                 ret_ref |= 1;
12819         }
12820         return ret_ref;
12821 }
12822
12823 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
12824         LDKUpdateFulfillHTLC orig_conv;
12825         orig_conv.inner = (void*)(orig & (~1));
12826         orig_conv.is_owned = false;
12827         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
12828         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12829         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12830         long ret_ref = (long)ret_var.inner;
12831         if (ret_var.is_owned) {
12832                 ret_ref |= 1;
12833         }
12834         return ret_ref;
12835 }
12836
12837 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
12838         LDKUpdateFailHTLC this_obj_conv;
12839         this_obj_conv.inner = (void*)(this_obj & (~1));
12840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12841         UpdateFailHTLC_free(this_obj_conv);
12842 }
12843
12844 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
12845         LDKUpdateFailHTLC this_ptr_conv;
12846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12847         this_ptr_conv.is_owned = false;
12848         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12849         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
12850         return ret_arr;
12851 }
12852
12853 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12854         LDKUpdateFailHTLC this_ptr_conv;
12855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12856         this_ptr_conv.is_owned = false;
12857         LDKThirtyTwoBytes val_ref;
12858         CHECK(*((uint32_t*)val) == 32);
12859         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12860         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
12861 }
12862
12863 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
12864         LDKUpdateFailHTLC this_ptr_conv;
12865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12866         this_ptr_conv.is_owned = false;
12867         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
12868         return ret_val;
12869 }
12870
12871 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12872         LDKUpdateFailHTLC this_ptr_conv;
12873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12874         this_ptr_conv.is_owned = false;
12875         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
12876 }
12877
12878 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
12879         LDKUpdateFailHTLC orig_conv;
12880         orig_conv.inner = (void*)(orig & (~1));
12881         orig_conv.is_owned = false;
12882         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
12883         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12884         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12885         long ret_ref = (long)ret_var.inner;
12886         if (ret_var.is_owned) {
12887                 ret_ref |= 1;
12888         }
12889         return ret_ref;
12890 }
12891
12892 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
12893         LDKUpdateFailMalformedHTLC this_obj_conv;
12894         this_obj_conv.inner = (void*)(this_obj & (~1));
12895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12896         UpdateFailMalformedHTLC_free(this_obj_conv);
12897 }
12898
12899 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
12900         LDKUpdateFailMalformedHTLC this_ptr_conv;
12901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12902         this_ptr_conv.is_owned = false;
12903         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12904         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
12905         return ret_arr;
12906 }
12907
12908 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12909         LDKUpdateFailMalformedHTLC this_ptr_conv;
12910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12911         this_ptr_conv.is_owned = false;
12912         LDKThirtyTwoBytes val_ref;
12913         CHECK(*((uint32_t*)val) == 32);
12914         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12915         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
12916 }
12917
12918 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
12919         LDKUpdateFailMalformedHTLC this_ptr_conv;
12920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12921         this_ptr_conv.is_owned = false;
12922         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
12923         return ret_val;
12924 }
12925
12926 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
12927         LDKUpdateFailMalformedHTLC this_ptr_conv;
12928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12929         this_ptr_conv.is_owned = false;
12930         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
12931 }
12932
12933 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
12934         LDKUpdateFailMalformedHTLC this_ptr_conv;
12935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12936         this_ptr_conv.is_owned = false;
12937         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
12938         return ret_val;
12939 }
12940
12941 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
12942         LDKUpdateFailMalformedHTLC this_ptr_conv;
12943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12944         this_ptr_conv.is_owned = false;
12945         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
12946 }
12947
12948 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
12949         LDKUpdateFailMalformedHTLC orig_conv;
12950         orig_conv.inner = (void*)(orig & (~1));
12951         orig_conv.is_owned = false;
12952         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
12953         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12954         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12955         long ret_ref = (long)ret_var.inner;
12956         if (ret_var.is_owned) {
12957                 ret_ref |= 1;
12958         }
12959         return ret_ref;
12960 }
12961
12962 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
12963         LDKCommitmentSigned this_obj_conv;
12964         this_obj_conv.inner = (void*)(this_obj & (~1));
12965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12966         CommitmentSigned_free(this_obj_conv);
12967 }
12968
12969 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
12970         LDKCommitmentSigned this_ptr_conv;
12971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12972         this_ptr_conv.is_owned = false;
12973         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12974         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
12975         return ret_arr;
12976 }
12977
12978 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
12979         LDKCommitmentSigned this_ptr_conv;
12980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12981         this_ptr_conv.is_owned = false;
12982         LDKThirtyTwoBytes val_ref;
12983         CHECK(*((uint32_t*)val) == 32);
12984         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
12985         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
12986 }
12987
12988 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
12989         LDKCommitmentSigned this_ptr_conv;
12990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12991         this_ptr_conv.is_owned = false;
12992         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
12993         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
12994         return ret_arr;
12995 }
12996
12997 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
12998         LDKCommitmentSigned this_ptr_conv;
12999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13000         this_ptr_conv.is_owned = false;
13001         LDKSignature val_ref;
13002         CHECK(*((uint32_t*)val) == 64);
13003         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13004         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
13005 }
13006
13007 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
13008         LDKCommitmentSigned this_ptr_conv;
13009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13010         this_ptr_conv.is_owned = false;
13011         LDKCVec_SignatureZ val_constr;
13012         val_constr.datalen = *((uint32_t*)val);
13013         if (val_constr.datalen > 0)
13014                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13015         else
13016                 val_constr.data = NULL;
13017         int8_tArray* val_vals = (int8_tArray*)(val + 4);
13018         for (size_t m = 0; m < val_constr.datalen; m++) {
13019                 int8_tArray val_conv_12 = val_vals[m];
13020                 LDKSignature val_conv_12_ref;
13021                 CHECK(*((uint32_t*)val_conv_12) == 64);
13022                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
13023                 val_constr.data[m] = val_conv_12_ref;
13024         }
13025         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
13026 }
13027
13028 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
13029         LDKThirtyTwoBytes channel_id_arg_ref;
13030         CHECK(*((uint32_t*)channel_id_arg) == 32);
13031         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13032         LDKSignature signature_arg_ref;
13033         CHECK(*((uint32_t*)signature_arg) == 64);
13034         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13035         LDKCVec_SignatureZ htlc_signatures_arg_constr;
13036         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
13037         if (htlc_signatures_arg_constr.datalen > 0)
13038                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13039         else
13040                 htlc_signatures_arg_constr.data = NULL;
13041         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
13042         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
13043                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
13044                 LDKSignature htlc_signatures_arg_conv_12_ref;
13045                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
13046                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
13047                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
13048         }
13049         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
13050         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13051         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13052         long ret_ref = (long)ret_var.inner;
13053         if (ret_var.is_owned) {
13054                 ret_ref |= 1;
13055         }
13056         return ret_ref;
13057 }
13058
13059 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
13060         LDKCommitmentSigned orig_conv;
13061         orig_conv.inner = (void*)(orig & (~1));
13062         orig_conv.is_owned = false;
13063         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
13064         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13065         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13066         long ret_ref = (long)ret_var.inner;
13067         if (ret_var.is_owned) {
13068                 ret_ref |= 1;
13069         }
13070         return ret_ref;
13071 }
13072
13073 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
13074         LDKRevokeAndACK this_obj_conv;
13075         this_obj_conv.inner = (void*)(this_obj & (~1));
13076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13077         RevokeAndACK_free(this_obj_conv);
13078 }
13079
13080 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
13081         LDKRevokeAndACK this_ptr_conv;
13082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13083         this_ptr_conv.is_owned = false;
13084         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13085         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
13086         return ret_arr;
13087 }
13088
13089 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13090         LDKRevokeAndACK this_ptr_conv;
13091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13092         this_ptr_conv.is_owned = false;
13093         LDKThirtyTwoBytes val_ref;
13094         CHECK(*((uint32_t*)val) == 32);
13095         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13096         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
13097 }
13098
13099 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
13100         LDKRevokeAndACK this_ptr_conv;
13101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13102         this_ptr_conv.is_owned = false;
13103         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13104         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
13105         return ret_arr;
13106 }
13107
13108 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13109         LDKRevokeAndACK this_ptr_conv;
13110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13111         this_ptr_conv.is_owned = false;
13112         LDKThirtyTwoBytes val_ref;
13113         CHECK(*((uint32_t*)val) == 32);
13114         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13115         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
13116 }
13117
13118 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
13119         LDKRevokeAndACK this_ptr_conv;
13120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13121         this_ptr_conv.is_owned = false;
13122         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13123         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13124         return ret_arr;
13125 }
13126
13127 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13128         LDKRevokeAndACK this_ptr_conv;
13129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13130         this_ptr_conv.is_owned = false;
13131         LDKPublicKey val_ref;
13132         CHECK(*((uint32_t*)val) == 33);
13133         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13134         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
13135 }
13136
13137 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) {
13138         LDKThirtyTwoBytes channel_id_arg_ref;
13139         CHECK(*((uint32_t*)channel_id_arg) == 32);
13140         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13141         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
13142         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
13143         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
13144         LDKPublicKey next_per_commitment_point_arg_ref;
13145         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
13146         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
13147         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
13148         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13149         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13150         long ret_ref = (long)ret_var.inner;
13151         if (ret_var.is_owned) {
13152                 ret_ref |= 1;
13153         }
13154         return ret_ref;
13155 }
13156
13157 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
13158         LDKRevokeAndACK orig_conv;
13159         orig_conv.inner = (void*)(orig & (~1));
13160         orig_conv.is_owned = false;
13161         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
13162         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13163         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13164         long ret_ref = (long)ret_var.inner;
13165         if (ret_var.is_owned) {
13166                 ret_ref |= 1;
13167         }
13168         return ret_ref;
13169 }
13170
13171 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
13172         LDKUpdateFee this_obj_conv;
13173         this_obj_conv.inner = (void*)(this_obj & (~1));
13174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13175         UpdateFee_free(this_obj_conv);
13176 }
13177
13178 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
13179         LDKUpdateFee this_ptr_conv;
13180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13181         this_ptr_conv.is_owned = false;
13182         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13183         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
13184         return ret_arr;
13185 }
13186
13187 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13188         LDKUpdateFee this_ptr_conv;
13189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13190         this_ptr_conv.is_owned = false;
13191         LDKThirtyTwoBytes val_ref;
13192         CHECK(*((uint32_t*)val) == 32);
13193         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13194         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
13195 }
13196
13197 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
13198         LDKUpdateFee this_ptr_conv;
13199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13200         this_ptr_conv.is_owned = false;
13201         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
13202         return ret_val;
13203 }
13204
13205 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
13206         LDKUpdateFee this_ptr_conv;
13207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13208         this_ptr_conv.is_owned = false;
13209         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
13210 }
13211
13212 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
13213         LDKThirtyTwoBytes channel_id_arg_ref;
13214         CHECK(*((uint32_t*)channel_id_arg) == 32);
13215         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13216         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
13217         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13218         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13219         long ret_ref = (long)ret_var.inner;
13220         if (ret_var.is_owned) {
13221                 ret_ref |= 1;
13222         }
13223         return ret_ref;
13224 }
13225
13226 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
13227         LDKUpdateFee orig_conv;
13228         orig_conv.inner = (void*)(orig & (~1));
13229         orig_conv.is_owned = false;
13230         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
13231         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13232         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13233         long ret_ref = (long)ret_var.inner;
13234         if (ret_var.is_owned) {
13235                 ret_ref |= 1;
13236         }
13237         return ret_ref;
13238 }
13239
13240 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
13241         LDKDataLossProtect this_obj_conv;
13242         this_obj_conv.inner = (void*)(this_obj & (~1));
13243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13244         DataLossProtect_free(this_obj_conv);
13245 }
13246
13247 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
13248         LDKDataLossProtect this_ptr_conv;
13249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13250         this_ptr_conv.is_owned = false;
13251         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13252         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
13253         return ret_arr;
13254 }
13255
13256 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
13257         LDKDataLossProtect this_ptr_conv;
13258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13259         this_ptr_conv.is_owned = false;
13260         LDKThirtyTwoBytes val_ref;
13261         CHECK(*((uint32_t*)val) == 32);
13262         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13263         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
13264 }
13265
13266 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
13267         LDKDataLossProtect this_ptr_conv;
13268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13269         this_ptr_conv.is_owned = false;
13270         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13271         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13272         return ret_arr;
13273 }
13274
13275 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13276         LDKDataLossProtect this_ptr_conv;
13277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13278         this_ptr_conv.is_owned = false;
13279         LDKPublicKey val_ref;
13280         CHECK(*((uint32_t*)val) == 33);
13281         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13282         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
13283 }
13284
13285 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
13286         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
13287         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
13288         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
13289         LDKPublicKey my_current_per_commitment_point_arg_ref;
13290         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
13291         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
13292         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
13293         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13294         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13295         long ret_ref = (long)ret_var.inner;
13296         if (ret_var.is_owned) {
13297                 ret_ref |= 1;
13298         }
13299         return ret_ref;
13300 }
13301
13302 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
13303         LDKDataLossProtect orig_conv;
13304         orig_conv.inner = (void*)(orig & (~1));
13305         orig_conv.is_owned = false;
13306         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
13307         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13308         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13309         long ret_ref = (long)ret_var.inner;
13310         if (ret_var.is_owned) {
13311                 ret_ref |= 1;
13312         }
13313         return ret_ref;
13314 }
13315
13316 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
13317         LDKChannelReestablish this_obj_conv;
13318         this_obj_conv.inner = (void*)(this_obj & (~1));
13319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13320         ChannelReestablish_free(this_obj_conv);
13321 }
13322
13323 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
13324         LDKChannelReestablish this_ptr_conv;
13325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13326         this_ptr_conv.is_owned = false;
13327         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13328         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
13329         return ret_arr;
13330 }
13331
13332 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13333         LDKChannelReestablish this_ptr_conv;
13334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13335         this_ptr_conv.is_owned = false;
13336         LDKThirtyTwoBytes val_ref;
13337         CHECK(*((uint32_t*)val) == 32);
13338         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13339         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
13340 }
13341
13342 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
13343         LDKChannelReestablish this_ptr_conv;
13344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13345         this_ptr_conv.is_owned = false;
13346         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
13347         return ret_val;
13348 }
13349
13350 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
13351         LDKChannelReestablish this_ptr_conv;
13352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13353         this_ptr_conv.is_owned = false;
13354         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
13355 }
13356
13357 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
13358         LDKChannelReestablish this_ptr_conv;
13359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13360         this_ptr_conv.is_owned = false;
13361         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
13362         return ret_val;
13363 }
13364
13365 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
13366         LDKChannelReestablish this_ptr_conv;
13367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13368         this_ptr_conv.is_owned = false;
13369         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
13370 }
13371
13372 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
13373         LDKChannelReestablish orig_conv;
13374         orig_conv.inner = (void*)(orig & (~1));
13375         orig_conv.is_owned = false;
13376         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
13377         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13378         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13379         long ret_ref = (long)ret_var.inner;
13380         if (ret_var.is_owned) {
13381                 ret_ref |= 1;
13382         }
13383         return ret_ref;
13384 }
13385
13386 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
13387         LDKAnnouncementSignatures this_obj_conv;
13388         this_obj_conv.inner = (void*)(this_obj & (~1));
13389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13390         AnnouncementSignatures_free(this_obj_conv);
13391 }
13392
13393 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
13394         LDKAnnouncementSignatures this_ptr_conv;
13395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13396         this_ptr_conv.is_owned = false;
13397         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13398         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
13399         return ret_arr;
13400 }
13401
13402 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
13403         LDKAnnouncementSignatures this_ptr_conv;
13404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13405         this_ptr_conv.is_owned = false;
13406         LDKThirtyTwoBytes val_ref;
13407         CHECK(*((uint32_t*)val) == 32);
13408         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13409         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
13410 }
13411
13412 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
13413         LDKAnnouncementSignatures this_ptr_conv;
13414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13415         this_ptr_conv.is_owned = false;
13416         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
13417         return ret_val;
13418 }
13419
13420 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
13421         LDKAnnouncementSignatures this_ptr_conv;
13422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13423         this_ptr_conv.is_owned = false;
13424         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
13425 }
13426
13427 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
13428         LDKAnnouncementSignatures this_ptr_conv;
13429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13430         this_ptr_conv.is_owned = false;
13431         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13432         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
13433         return ret_arr;
13434 }
13435
13436 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
13437         LDKAnnouncementSignatures this_ptr_conv;
13438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13439         this_ptr_conv.is_owned = false;
13440         LDKSignature val_ref;
13441         CHECK(*((uint32_t*)val) == 64);
13442         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13443         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
13444 }
13445
13446 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
13447         LDKAnnouncementSignatures this_ptr_conv;
13448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13449         this_ptr_conv.is_owned = false;
13450         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13451         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
13452         return ret_arr;
13453 }
13454
13455 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
13456         LDKAnnouncementSignatures this_ptr_conv;
13457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13458         this_ptr_conv.is_owned = false;
13459         LDKSignature val_ref;
13460         CHECK(*((uint32_t*)val) == 64);
13461         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13462         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
13463 }
13464
13465 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) {
13466         LDKThirtyTwoBytes channel_id_arg_ref;
13467         CHECK(*((uint32_t*)channel_id_arg) == 32);
13468         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
13469         LDKSignature node_signature_arg_ref;
13470         CHECK(*((uint32_t*)node_signature_arg) == 64);
13471         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
13472         LDKSignature bitcoin_signature_arg_ref;
13473         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
13474         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
13475         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
13476         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13477         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13478         long ret_ref = (long)ret_var.inner;
13479         if (ret_var.is_owned) {
13480                 ret_ref |= 1;
13481         }
13482         return ret_ref;
13483 }
13484
13485 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
13486         LDKAnnouncementSignatures orig_conv;
13487         orig_conv.inner = (void*)(orig & (~1));
13488         orig_conv.is_owned = false;
13489         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
13490         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13491         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13492         long ret_ref = (long)ret_var.inner;
13493         if (ret_var.is_owned) {
13494                 ret_ref |= 1;
13495         }
13496         return ret_ref;
13497 }
13498
13499 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
13500         if ((this_ptr & 1) != 0) return;
13501         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
13502         FREE((void*)this_ptr);
13503         NetAddress_free(this_ptr_conv);
13504 }
13505
13506 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
13507         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
13508         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
13509         *ret_copy = NetAddress_clone(orig_conv);
13510         long ret_ref = (long)ret_copy;
13511         return ret_ref;
13512 }
13513
13514 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
13515         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
13516         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
13517         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13518         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13519         CVec_u8Z_free(ret_var);
13520         return ret_arr;
13521 }
13522
13523 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
13524         LDKu8slice ser_ref;
13525         ser_ref.datalen = *((uint32_t*)ser);
13526         ser_ref.data = (int8_t*)(ser + 4);
13527         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
13528         *ret_conv = Result_read(ser_ref);
13529         return (long)ret_conv;
13530 }
13531
13532 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
13533         LDKUnsignedNodeAnnouncement this_obj_conv;
13534         this_obj_conv.inner = (void*)(this_obj & (~1));
13535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13536         UnsignedNodeAnnouncement_free(this_obj_conv);
13537 }
13538
13539 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
13540         LDKUnsignedNodeAnnouncement this_ptr_conv;
13541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13542         this_ptr_conv.is_owned = false;
13543         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
13544         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13545         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13546         long ret_ref = (long)ret_var.inner;
13547         if (ret_var.is_owned) {
13548                 ret_ref |= 1;
13549         }
13550         return ret_ref;
13551 }
13552
13553 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
13554         LDKUnsignedNodeAnnouncement this_ptr_conv;
13555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13556         this_ptr_conv.is_owned = false;
13557         LDKNodeFeatures val_conv;
13558         val_conv.inner = (void*)(val & (~1));
13559         val_conv.is_owned = (val & 1) || (val == 0);
13560         val_conv = NodeFeatures_clone(&val_conv);
13561         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
13562 }
13563
13564 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
13565         LDKUnsignedNodeAnnouncement this_ptr_conv;
13566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13567         this_ptr_conv.is_owned = false;
13568         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
13569         return ret_val;
13570 }
13571
13572 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
13573         LDKUnsignedNodeAnnouncement this_ptr_conv;
13574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13575         this_ptr_conv.is_owned = false;
13576         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
13577 }
13578
13579 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
13580         LDKUnsignedNodeAnnouncement this_ptr_conv;
13581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13582         this_ptr_conv.is_owned = false;
13583         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13584         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
13585         return ret_arr;
13586 }
13587
13588 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
13589         LDKUnsignedNodeAnnouncement this_ptr_conv;
13590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13591         this_ptr_conv.is_owned = false;
13592         LDKPublicKey val_ref;
13593         CHECK(*((uint32_t*)val) == 33);
13594         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13595         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
13596 }
13597
13598 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
13599         LDKUnsignedNodeAnnouncement this_ptr_conv;
13600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13601         this_ptr_conv.is_owned = false;
13602         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
13603         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
13604         return ret_arr;
13605 }
13606
13607 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
13608         LDKUnsignedNodeAnnouncement this_ptr_conv;
13609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13610         this_ptr_conv.is_owned = false;
13611         LDKThreeBytes val_ref;
13612         CHECK(*((uint32_t*)val) == 3);
13613         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
13614         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
13615 }
13616
13617 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
13618         LDKUnsignedNodeAnnouncement this_ptr_conv;
13619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13620         this_ptr_conv.is_owned = false;
13621         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13622         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
13623         return ret_arr;
13624 }
13625
13626 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
13627         LDKUnsignedNodeAnnouncement this_ptr_conv;
13628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13629         this_ptr_conv.is_owned = false;
13630         LDKThirtyTwoBytes val_ref;
13631         CHECK(*((uint32_t*)val) == 32);
13632         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13633         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
13634 }
13635
13636 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
13637         LDKUnsignedNodeAnnouncement this_ptr_conv;
13638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13639         this_ptr_conv.is_owned = false;
13640         LDKCVec_NetAddressZ val_constr;
13641         val_constr.datalen = *((uint32_t*)val);
13642         if (val_constr.datalen > 0)
13643                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13644         else
13645                 val_constr.data = NULL;
13646         uint32_t* val_vals = (uint32_t*)(val + 4);
13647         for (size_t m = 0; m < val_constr.datalen; m++) {
13648                 uint32_t val_conv_12 = val_vals[m];
13649                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
13650                 FREE((void*)val_conv_12);
13651                 val_constr.data[m] = val_conv_12_conv;
13652         }
13653         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
13654 }
13655
13656 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
13657         LDKUnsignedNodeAnnouncement orig_conv;
13658         orig_conv.inner = (void*)(orig & (~1));
13659         orig_conv.is_owned = false;
13660         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
13661         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13662         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13663         long ret_ref = (long)ret_var.inner;
13664         if (ret_var.is_owned) {
13665                 ret_ref |= 1;
13666         }
13667         return ret_ref;
13668 }
13669
13670 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
13671         LDKNodeAnnouncement this_obj_conv;
13672         this_obj_conv.inner = (void*)(this_obj & (~1));
13673         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13674         NodeAnnouncement_free(this_obj_conv);
13675 }
13676
13677 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
13678         LDKNodeAnnouncement this_ptr_conv;
13679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13680         this_ptr_conv.is_owned = false;
13681         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13682         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
13683         return ret_arr;
13684 }
13685
13686 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
13687         LDKNodeAnnouncement this_ptr_conv;
13688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13689         this_ptr_conv.is_owned = false;
13690         LDKSignature val_ref;
13691         CHECK(*((uint32_t*)val) == 64);
13692         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13693         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
13694 }
13695
13696 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
13697         LDKNodeAnnouncement this_ptr_conv;
13698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13699         this_ptr_conv.is_owned = false;
13700         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
13701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13703         long ret_ref = (long)ret_var.inner;
13704         if (ret_var.is_owned) {
13705                 ret_ref |= 1;
13706         }
13707         return ret_ref;
13708 }
13709
13710 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
13711         LDKNodeAnnouncement this_ptr_conv;
13712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13713         this_ptr_conv.is_owned = false;
13714         LDKUnsignedNodeAnnouncement val_conv;
13715         val_conv.inner = (void*)(val & (~1));
13716         val_conv.is_owned = (val & 1) || (val == 0);
13717         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
13718         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
13719 }
13720
13721 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
13722         LDKSignature signature_arg_ref;
13723         CHECK(*((uint32_t*)signature_arg) == 64);
13724         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
13725         LDKUnsignedNodeAnnouncement contents_arg_conv;
13726         contents_arg_conv.inner = (void*)(contents_arg & (~1));
13727         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
13728         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
13729         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
13730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13732         long ret_ref = (long)ret_var.inner;
13733         if (ret_var.is_owned) {
13734                 ret_ref |= 1;
13735         }
13736         return ret_ref;
13737 }
13738
13739 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
13740         LDKNodeAnnouncement orig_conv;
13741         orig_conv.inner = (void*)(orig & (~1));
13742         orig_conv.is_owned = false;
13743         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
13744         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13745         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13746         long ret_ref = (long)ret_var.inner;
13747         if (ret_var.is_owned) {
13748                 ret_ref |= 1;
13749         }
13750         return ret_ref;
13751 }
13752
13753 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
13754         LDKUnsignedChannelAnnouncement this_obj_conv;
13755         this_obj_conv.inner = (void*)(this_obj & (~1));
13756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13757         UnsignedChannelAnnouncement_free(this_obj_conv);
13758 }
13759
13760 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
13761         LDKUnsignedChannelAnnouncement this_ptr_conv;
13762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13763         this_ptr_conv.is_owned = false;
13764         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
13765         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13766         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13767         long ret_ref = (long)ret_var.inner;
13768         if (ret_var.is_owned) {
13769                 ret_ref |= 1;
13770         }
13771         return ret_ref;
13772 }
13773
13774 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
13775         LDKUnsignedChannelAnnouncement this_ptr_conv;
13776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13777         this_ptr_conv.is_owned = false;
13778         LDKChannelFeatures val_conv;
13779         val_conv.inner = (void*)(val & (~1));
13780         val_conv.is_owned = (val & 1) || (val == 0);
13781         val_conv = ChannelFeatures_clone(&val_conv);
13782         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
13783 }
13784
13785 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
13786         LDKUnsignedChannelAnnouncement this_ptr_conv;
13787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13788         this_ptr_conv.is_owned = false;
13789         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13790         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
13791         return ret_arr;
13792 }
13793
13794 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
13795         LDKUnsignedChannelAnnouncement this_ptr_conv;
13796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13797         this_ptr_conv.is_owned = false;
13798         LDKThirtyTwoBytes val_ref;
13799         CHECK(*((uint32_t*)val) == 32);
13800         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13801         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
13802 }
13803
13804 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
13805         LDKUnsignedChannelAnnouncement this_ptr_conv;
13806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13807         this_ptr_conv.is_owned = false;
13808         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
13809         return ret_val;
13810 }
13811
13812 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
13813         LDKUnsignedChannelAnnouncement this_ptr_conv;
13814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13815         this_ptr_conv.is_owned = false;
13816         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
13817 }
13818
13819 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
13820         LDKUnsignedChannelAnnouncement this_ptr_conv;
13821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13822         this_ptr_conv.is_owned = false;
13823         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13824         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
13825         return ret_arr;
13826 }
13827
13828 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
13829         LDKUnsignedChannelAnnouncement this_ptr_conv;
13830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13831         this_ptr_conv.is_owned = false;
13832         LDKPublicKey val_ref;
13833         CHECK(*((uint32_t*)val) == 33);
13834         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13835         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
13836 }
13837
13838 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
13839         LDKUnsignedChannelAnnouncement this_ptr_conv;
13840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13841         this_ptr_conv.is_owned = false;
13842         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13843         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
13844         return ret_arr;
13845 }
13846
13847 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
13848         LDKUnsignedChannelAnnouncement this_ptr_conv;
13849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13850         this_ptr_conv.is_owned = false;
13851         LDKPublicKey val_ref;
13852         CHECK(*((uint32_t*)val) == 33);
13853         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13854         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
13855 }
13856
13857 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
13858         LDKUnsignedChannelAnnouncement this_ptr_conv;
13859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13860         this_ptr_conv.is_owned = false;
13861         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13862         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
13863         return ret_arr;
13864 }
13865
13866 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
13867         LDKUnsignedChannelAnnouncement this_ptr_conv;
13868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13869         this_ptr_conv.is_owned = false;
13870         LDKPublicKey val_ref;
13871         CHECK(*((uint32_t*)val) == 33);
13872         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13873         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
13874 }
13875
13876 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
13877         LDKUnsignedChannelAnnouncement this_ptr_conv;
13878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13879         this_ptr_conv.is_owned = false;
13880         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13881         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
13882         return ret_arr;
13883 }
13884
13885 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
13886         LDKUnsignedChannelAnnouncement this_ptr_conv;
13887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13888         this_ptr_conv.is_owned = false;
13889         LDKPublicKey val_ref;
13890         CHECK(*((uint32_t*)val) == 33);
13891         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13892         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
13893 }
13894
13895 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
13896         LDKUnsignedChannelAnnouncement orig_conv;
13897         orig_conv.inner = (void*)(orig & (~1));
13898         orig_conv.is_owned = false;
13899         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
13900         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13901         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13902         long ret_ref = (long)ret_var.inner;
13903         if (ret_var.is_owned) {
13904                 ret_ref |= 1;
13905         }
13906         return ret_ref;
13907 }
13908
13909 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
13910         LDKChannelAnnouncement this_obj_conv;
13911         this_obj_conv.inner = (void*)(this_obj & (~1));
13912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13913         ChannelAnnouncement_free(this_obj_conv);
13914 }
13915
13916 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
13917         LDKChannelAnnouncement this_ptr_conv;
13918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13919         this_ptr_conv.is_owned = false;
13920         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13921         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
13922         return ret_arr;
13923 }
13924
13925 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
13926         LDKChannelAnnouncement this_ptr_conv;
13927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13928         this_ptr_conv.is_owned = false;
13929         LDKSignature val_ref;
13930         CHECK(*((uint32_t*)val) == 64);
13931         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13932         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
13933 }
13934
13935 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
13936         LDKChannelAnnouncement this_ptr_conv;
13937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13938         this_ptr_conv.is_owned = false;
13939         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13940         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
13941         return ret_arr;
13942 }
13943
13944 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
13945         LDKChannelAnnouncement this_ptr_conv;
13946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13947         this_ptr_conv.is_owned = false;
13948         LDKSignature val_ref;
13949         CHECK(*((uint32_t*)val) == 64);
13950         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13951         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
13952 }
13953
13954 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
13955         LDKChannelAnnouncement this_ptr_conv;
13956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13957         this_ptr_conv.is_owned = false;
13958         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13959         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
13960         return ret_arr;
13961 }
13962
13963 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
13964         LDKChannelAnnouncement this_ptr_conv;
13965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13966         this_ptr_conv.is_owned = false;
13967         LDKSignature val_ref;
13968         CHECK(*((uint32_t*)val) == 64);
13969         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13970         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
13971 }
13972
13973 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
13974         LDKChannelAnnouncement this_ptr_conv;
13975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13976         this_ptr_conv.is_owned = false;
13977         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13978         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
13979         return ret_arr;
13980 }
13981
13982 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
13983         LDKChannelAnnouncement this_ptr_conv;
13984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13985         this_ptr_conv.is_owned = false;
13986         LDKSignature val_ref;
13987         CHECK(*((uint32_t*)val) == 64);
13988         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13989         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
13990 }
13991
13992 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
13993         LDKChannelAnnouncement this_ptr_conv;
13994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13995         this_ptr_conv.is_owned = false;
13996         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
13997         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13998         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13999         long ret_ref = (long)ret_var.inner;
14000         if (ret_var.is_owned) {
14001                 ret_ref |= 1;
14002         }
14003         return ret_ref;
14004 }
14005
14006 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
14007         LDKChannelAnnouncement this_ptr_conv;
14008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14009         this_ptr_conv.is_owned = false;
14010         LDKUnsignedChannelAnnouncement val_conv;
14011         val_conv.inner = (void*)(val & (~1));
14012         val_conv.is_owned = (val & 1) || (val == 0);
14013         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
14014         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
14015 }
14016
14017 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) {
14018         LDKSignature node_signature_1_arg_ref;
14019         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
14020         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
14021         LDKSignature node_signature_2_arg_ref;
14022         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
14023         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
14024         LDKSignature bitcoin_signature_1_arg_ref;
14025         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
14026         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
14027         LDKSignature bitcoin_signature_2_arg_ref;
14028         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
14029         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
14030         LDKUnsignedChannelAnnouncement contents_arg_conv;
14031         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14032         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14033         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
14034         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);
14035         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14036         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14037         long ret_ref = (long)ret_var.inner;
14038         if (ret_var.is_owned) {
14039                 ret_ref |= 1;
14040         }
14041         return ret_ref;
14042 }
14043
14044 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
14045         LDKChannelAnnouncement orig_conv;
14046         orig_conv.inner = (void*)(orig & (~1));
14047         orig_conv.is_owned = false;
14048         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
14049         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14050         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14051         long ret_ref = (long)ret_var.inner;
14052         if (ret_var.is_owned) {
14053                 ret_ref |= 1;
14054         }
14055         return ret_ref;
14056 }
14057
14058 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
14059         LDKUnsignedChannelUpdate this_obj_conv;
14060         this_obj_conv.inner = (void*)(this_obj & (~1));
14061         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14062         UnsignedChannelUpdate_free(this_obj_conv);
14063 }
14064
14065 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
14066         LDKUnsignedChannelUpdate this_ptr_conv;
14067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14068         this_ptr_conv.is_owned = false;
14069         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14070         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
14071         return ret_arr;
14072 }
14073
14074 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14075         LDKUnsignedChannelUpdate this_ptr_conv;
14076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14077         this_ptr_conv.is_owned = false;
14078         LDKThirtyTwoBytes val_ref;
14079         CHECK(*((uint32_t*)val) == 32);
14080         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14081         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
14082 }
14083
14084 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
14085         LDKUnsignedChannelUpdate this_ptr_conv;
14086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14087         this_ptr_conv.is_owned = false;
14088         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
14089         return ret_val;
14090 }
14091
14092 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14093         LDKUnsignedChannelUpdate this_ptr_conv;
14094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14095         this_ptr_conv.is_owned = false;
14096         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
14097 }
14098
14099 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
14100         LDKUnsignedChannelUpdate this_ptr_conv;
14101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14102         this_ptr_conv.is_owned = false;
14103         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
14104         return ret_val;
14105 }
14106
14107 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
14108         LDKUnsignedChannelUpdate this_ptr_conv;
14109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14110         this_ptr_conv.is_owned = false;
14111         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
14112 }
14113
14114 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
14115         LDKUnsignedChannelUpdate this_ptr_conv;
14116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14117         this_ptr_conv.is_owned = false;
14118         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
14119         return ret_val;
14120 }
14121
14122 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
14123         LDKUnsignedChannelUpdate this_ptr_conv;
14124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14125         this_ptr_conv.is_owned = false;
14126         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
14127 }
14128
14129 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
14130         LDKUnsignedChannelUpdate this_ptr_conv;
14131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14132         this_ptr_conv.is_owned = false;
14133         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
14134         return ret_val;
14135 }
14136
14137 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14138         LDKUnsignedChannelUpdate this_ptr_conv;
14139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14140         this_ptr_conv.is_owned = false;
14141         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
14142 }
14143
14144 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
14145         LDKUnsignedChannelUpdate this_ptr_conv;
14146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14147         this_ptr_conv.is_owned = false;
14148         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
14149         return ret_val;
14150 }
14151
14152 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14153         LDKUnsignedChannelUpdate this_ptr_conv;
14154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14155         this_ptr_conv.is_owned = false;
14156         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
14157 }
14158
14159 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
14160         LDKUnsignedChannelUpdate this_ptr_conv;
14161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14162         this_ptr_conv.is_owned = false;
14163         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
14164         return ret_val;
14165 }
14166
14167 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
14168         LDKUnsignedChannelUpdate this_ptr_conv;
14169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14170         this_ptr_conv.is_owned = false;
14171         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
14172 }
14173
14174 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
14175         LDKUnsignedChannelUpdate this_ptr_conv;
14176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14177         this_ptr_conv.is_owned = false;
14178         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
14179         return ret_val;
14180 }
14181
14182 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
14183         LDKUnsignedChannelUpdate this_ptr_conv;
14184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14185         this_ptr_conv.is_owned = false;
14186         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
14187 }
14188
14189 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
14190         LDKUnsignedChannelUpdate orig_conv;
14191         orig_conv.inner = (void*)(orig & (~1));
14192         orig_conv.is_owned = false;
14193         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
14194         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14195         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14196         long ret_ref = (long)ret_var.inner;
14197         if (ret_var.is_owned) {
14198                 ret_ref |= 1;
14199         }
14200         return ret_ref;
14201 }
14202
14203 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
14204         LDKChannelUpdate this_obj_conv;
14205         this_obj_conv.inner = (void*)(this_obj & (~1));
14206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14207         ChannelUpdate_free(this_obj_conv);
14208 }
14209
14210 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
14211         LDKChannelUpdate this_ptr_conv;
14212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14213         this_ptr_conv.is_owned = false;
14214         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14215         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
14216         return ret_arr;
14217 }
14218
14219 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
14220         LDKChannelUpdate this_ptr_conv;
14221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14222         this_ptr_conv.is_owned = false;
14223         LDKSignature val_ref;
14224         CHECK(*((uint32_t*)val) == 64);
14225         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14226         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
14227 }
14228
14229 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
14230         LDKChannelUpdate this_ptr_conv;
14231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14232         this_ptr_conv.is_owned = false;
14233         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
14234         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14235         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14236         long ret_ref = (long)ret_var.inner;
14237         if (ret_var.is_owned) {
14238                 ret_ref |= 1;
14239         }
14240         return ret_ref;
14241 }
14242
14243 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
14244         LDKChannelUpdate this_ptr_conv;
14245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14246         this_ptr_conv.is_owned = false;
14247         LDKUnsignedChannelUpdate val_conv;
14248         val_conv.inner = (void*)(val & (~1));
14249         val_conv.is_owned = (val & 1) || (val == 0);
14250         val_conv = UnsignedChannelUpdate_clone(&val_conv);
14251         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
14252 }
14253
14254 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
14255         LDKSignature signature_arg_ref;
14256         CHECK(*((uint32_t*)signature_arg) == 64);
14257         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
14258         LDKUnsignedChannelUpdate contents_arg_conv;
14259         contents_arg_conv.inner = (void*)(contents_arg & (~1));
14260         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
14261         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
14262         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
14263         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14264         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14265         long ret_ref = (long)ret_var.inner;
14266         if (ret_var.is_owned) {
14267                 ret_ref |= 1;
14268         }
14269         return ret_ref;
14270 }
14271
14272 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
14273         LDKChannelUpdate orig_conv;
14274         orig_conv.inner = (void*)(orig & (~1));
14275         orig_conv.is_owned = false;
14276         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
14277         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14278         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14279         long ret_ref = (long)ret_var.inner;
14280         if (ret_var.is_owned) {
14281                 ret_ref |= 1;
14282         }
14283         return ret_ref;
14284 }
14285
14286 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
14287         LDKQueryChannelRange this_obj_conv;
14288         this_obj_conv.inner = (void*)(this_obj & (~1));
14289         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14290         QueryChannelRange_free(this_obj_conv);
14291 }
14292
14293 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
14294         LDKQueryChannelRange this_ptr_conv;
14295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14296         this_ptr_conv.is_owned = false;
14297         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14298         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
14299         return ret_arr;
14300 }
14301
14302 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14303         LDKQueryChannelRange this_ptr_conv;
14304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14305         this_ptr_conv.is_owned = false;
14306         LDKThirtyTwoBytes val_ref;
14307         CHECK(*((uint32_t*)val) == 32);
14308         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14309         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14310 }
14311
14312 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
14313         LDKQueryChannelRange this_ptr_conv;
14314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14315         this_ptr_conv.is_owned = false;
14316         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
14317         return ret_val;
14318 }
14319
14320 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14321         LDKQueryChannelRange this_ptr_conv;
14322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14323         this_ptr_conv.is_owned = false;
14324         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
14325 }
14326
14327 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14328         LDKQueryChannelRange this_ptr_conv;
14329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14330         this_ptr_conv.is_owned = false;
14331         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
14332         return ret_val;
14333 }
14334
14335 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14336         LDKQueryChannelRange this_ptr_conv;
14337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14338         this_ptr_conv.is_owned = false;
14339         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14340 }
14341
14342 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
14343         LDKThirtyTwoBytes chain_hash_arg_ref;
14344         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14345         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14346         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
14347         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14348         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14349         long ret_ref = (long)ret_var.inner;
14350         if (ret_var.is_owned) {
14351                 ret_ref |= 1;
14352         }
14353         return ret_ref;
14354 }
14355
14356 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
14357         LDKQueryChannelRange orig_conv;
14358         orig_conv.inner = (void*)(orig & (~1));
14359         orig_conv.is_owned = false;
14360         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
14361         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14362         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14363         long ret_ref = (long)ret_var.inner;
14364         if (ret_var.is_owned) {
14365                 ret_ref |= 1;
14366         }
14367         return ret_ref;
14368 }
14369
14370 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
14371         LDKReplyChannelRange this_obj_conv;
14372         this_obj_conv.inner = (void*)(this_obj & (~1));
14373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14374         ReplyChannelRange_free(this_obj_conv);
14375 }
14376
14377 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
14378         LDKReplyChannelRange this_ptr_conv;
14379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14380         this_ptr_conv.is_owned = false;
14381         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14382         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
14383         return ret_arr;
14384 }
14385
14386 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14387         LDKReplyChannelRange this_ptr_conv;
14388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14389         this_ptr_conv.is_owned = false;
14390         LDKThirtyTwoBytes val_ref;
14391         CHECK(*((uint32_t*)val) == 32);
14392         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14393         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
14394 }
14395
14396 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
14397         LDKReplyChannelRange this_ptr_conv;
14398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14399         this_ptr_conv.is_owned = false;
14400         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
14401         return ret_val;
14402 }
14403
14404 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
14405         LDKReplyChannelRange this_ptr_conv;
14406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14407         this_ptr_conv.is_owned = false;
14408         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
14409 }
14410
14411 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
14412         LDKReplyChannelRange this_ptr_conv;
14413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14414         this_ptr_conv.is_owned = false;
14415         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
14416         return ret_val;
14417 }
14418
14419 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
14420         LDKReplyChannelRange this_ptr_conv;
14421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14422         this_ptr_conv.is_owned = false;
14423         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
14424 }
14425
14426 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
14427         LDKReplyChannelRange this_ptr_conv;
14428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14429         this_ptr_conv.is_owned = false;
14430         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
14431         return ret_val;
14432 }
14433
14434 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
14435         LDKReplyChannelRange this_ptr_conv;
14436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14437         this_ptr_conv.is_owned = false;
14438         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
14439 }
14440
14441 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14442         LDKReplyChannelRange this_ptr_conv;
14443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14444         this_ptr_conv.is_owned = false;
14445         LDKCVec_u64Z val_constr;
14446         val_constr.datalen = *((uint32_t*)val);
14447         if (val_constr.datalen > 0)
14448                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14449         else
14450                 val_constr.data = NULL;
14451         int64_t* val_vals = (int64_t*)(val + 4);
14452         for (size_t i = 0; i < val_constr.datalen; i++) {
14453                 int64_t val_conv_8 = val_vals[i];
14454                 val_constr.data[i] = val_conv_8;
14455         }
14456         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
14457 }
14458
14459 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) {
14460         LDKThirtyTwoBytes chain_hash_arg_ref;
14461         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14462         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14463         LDKCVec_u64Z short_channel_ids_arg_constr;
14464         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14465         if (short_channel_ids_arg_constr.datalen > 0)
14466                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14467         else
14468                 short_channel_ids_arg_constr.data = NULL;
14469         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14470         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14471                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14472                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14473         }
14474         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
14475         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14476         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14477         long ret_ref = (long)ret_var.inner;
14478         if (ret_var.is_owned) {
14479                 ret_ref |= 1;
14480         }
14481         return ret_ref;
14482 }
14483
14484 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
14485         LDKReplyChannelRange orig_conv;
14486         orig_conv.inner = (void*)(orig & (~1));
14487         orig_conv.is_owned = false;
14488         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
14489         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14490         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14491         long ret_ref = (long)ret_var.inner;
14492         if (ret_var.is_owned) {
14493                 ret_ref |= 1;
14494         }
14495         return ret_ref;
14496 }
14497
14498 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
14499         LDKQueryShortChannelIds this_obj_conv;
14500         this_obj_conv.inner = (void*)(this_obj & (~1));
14501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14502         QueryShortChannelIds_free(this_obj_conv);
14503 }
14504
14505 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
14506         LDKQueryShortChannelIds this_ptr_conv;
14507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14508         this_ptr_conv.is_owned = false;
14509         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14510         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
14511         return ret_arr;
14512 }
14513
14514 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14515         LDKQueryShortChannelIds this_ptr_conv;
14516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14517         this_ptr_conv.is_owned = false;
14518         LDKThirtyTwoBytes val_ref;
14519         CHECK(*((uint32_t*)val) == 32);
14520         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14521         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
14522 }
14523
14524 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
14525         LDKQueryShortChannelIds this_ptr_conv;
14526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14527         this_ptr_conv.is_owned = false;
14528         LDKCVec_u64Z val_constr;
14529         val_constr.datalen = *((uint32_t*)val);
14530         if (val_constr.datalen > 0)
14531                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14532         else
14533                 val_constr.data = NULL;
14534         int64_t* val_vals = (int64_t*)(val + 4);
14535         for (size_t i = 0; i < val_constr.datalen; i++) {
14536                 int64_t val_conv_8 = val_vals[i];
14537                 val_constr.data[i] = val_conv_8;
14538         }
14539         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
14540 }
14541
14542 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
14543         LDKThirtyTwoBytes chain_hash_arg_ref;
14544         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14545         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14546         LDKCVec_u64Z short_channel_ids_arg_constr;
14547         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
14548         if (short_channel_ids_arg_constr.datalen > 0)
14549                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14550         else
14551                 short_channel_ids_arg_constr.data = NULL;
14552         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
14553         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
14554                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
14555                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
14556         }
14557         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
14558         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14559         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14560         long ret_ref = (long)ret_var.inner;
14561         if (ret_var.is_owned) {
14562                 ret_ref |= 1;
14563         }
14564         return ret_ref;
14565 }
14566
14567 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
14568         LDKQueryShortChannelIds orig_conv;
14569         orig_conv.inner = (void*)(orig & (~1));
14570         orig_conv.is_owned = false;
14571         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
14572         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14573         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14574         long ret_ref = (long)ret_var.inner;
14575         if (ret_var.is_owned) {
14576                 ret_ref |= 1;
14577         }
14578         return ret_ref;
14579 }
14580
14581 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
14582         LDKReplyShortChannelIdsEnd this_obj_conv;
14583         this_obj_conv.inner = (void*)(this_obj & (~1));
14584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14585         ReplyShortChannelIdsEnd_free(this_obj_conv);
14586 }
14587
14588 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
14589         LDKReplyShortChannelIdsEnd this_ptr_conv;
14590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14591         this_ptr_conv.is_owned = false;
14592         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14593         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
14594         return ret_arr;
14595 }
14596
14597 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14598         LDKReplyShortChannelIdsEnd this_ptr_conv;
14599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14600         this_ptr_conv.is_owned = false;
14601         LDKThirtyTwoBytes val_ref;
14602         CHECK(*((uint32_t*)val) == 32);
14603         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14604         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
14605 }
14606
14607 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
14608         LDKReplyShortChannelIdsEnd this_ptr_conv;
14609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14610         this_ptr_conv.is_owned = false;
14611         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
14612         return ret_val;
14613 }
14614
14615 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
14616         LDKReplyShortChannelIdsEnd this_ptr_conv;
14617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14618         this_ptr_conv.is_owned = false;
14619         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
14620 }
14621
14622 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
14623         LDKThirtyTwoBytes chain_hash_arg_ref;
14624         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14625         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14626         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
14627         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14628         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14629         long ret_ref = (long)ret_var.inner;
14630         if (ret_var.is_owned) {
14631                 ret_ref |= 1;
14632         }
14633         return ret_ref;
14634 }
14635
14636 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
14637         LDKReplyShortChannelIdsEnd orig_conv;
14638         orig_conv.inner = (void*)(orig & (~1));
14639         orig_conv.is_owned = false;
14640         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
14641         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14642         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14643         long ret_ref = (long)ret_var.inner;
14644         if (ret_var.is_owned) {
14645                 ret_ref |= 1;
14646         }
14647         return ret_ref;
14648 }
14649
14650 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
14651         LDKGossipTimestampFilter this_obj_conv;
14652         this_obj_conv.inner = (void*)(this_obj & (~1));
14653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14654         GossipTimestampFilter_free(this_obj_conv);
14655 }
14656
14657 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
14658         LDKGossipTimestampFilter this_ptr_conv;
14659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14660         this_ptr_conv.is_owned = false;
14661         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14662         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
14663         return ret_arr;
14664 }
14665
14666 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
14667         LDKGossipTimestampFilter this_ptr_conv;
14668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14669         this_ptr_conv.is_owned = false;
14670         LDKThirtyTwoBytes val_ref;
14671         CHECK(*((uint32_t*)val) == 32);
14672         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14673         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
14674 }
14675
14676 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
14677         LDKGossipTimestampFilter this_ptr_conv;
14678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14679         this_ptr_conv.is_owned = false;
14680         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
14681         return ret_val;
14682 }
14683
14684 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
14685         LDKGossipTimestampFilter this_ptr_conv;
14686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14687         this_ptr_conv.is_owned = false;
14688         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
14689 }
14690
14691 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
14692         LDKGossipTimestampFilter this_ptr_conv;
14693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14694         this_ptr_conv.is_owned = false;
14695         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
14696         return ret_val;
14697 }
14698
14699 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
14700         LDKGossipTimestampFilter this_ptr_conv;
14701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14702         this_ptr_conv.is_owned = false;
14703         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
14704 }
14705
14706 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
14707         LDKThirtyTwoBytes chain_hash_arg_ref;
14708         CHECK(*((uint32_t*)chain_hash_arg) == 32);
14709         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
14710         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
14711         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14712         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14713         long ret_ref = (long)ret_var.inner;
14714         if (ret_var.is_owned) {
14715                 ret_ref |= 1;
14716         }
14717         return ret_ref;
14718 }
14719
14720 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
14721         LDKGossipTimestampFilter orig_conv;
14722         orig_conv.inner = (void*)(orig & (~1));
14723         orig_conv.is_owned = false;
14724         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
14725         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14726         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14727         long ret_ref = (long)ret_var.inner;
14728         if (ret_var.is_owned) {
14729                 ret_ref |= 1;
14730         }
14731         return ret_ref;
14732 }
14733
14734 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
14735         if ((this_ptr & 1) != 0) return;
14736         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
14737         FREE((void*)this_ptr);
14738         ErrorAction_free(this_ptr_conv);
14739 }
14740
14741 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
14742         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
14743         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14744         *ret_copy = ErrorAction_clone(orig_conv);
14745         long ret_ref = (long)ret_copy;
14746         return ret_ref;
14747 }
14748
14749 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
14750         LDKLightningError this_obj_conv;
14751         this_obj_conv.inner = (void*)(this_obj & (~1));
14752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14753         LightningError_free(this_obj_conv);
14754 }
14755
14756 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
14757         LDKLightningError this_ptr_conv;
14758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14759         this_ptr_conv.is_owned = false;
14760         LDKStr _str = LightningError_get_err(&this_ptr_conv);
14761         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
14762         return _conv;
14763 }
14764
14765 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
14766         LDKLightningError this_ptr_conv;
14767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14768         this_ptr_conv.is_owned = false;
14769         LDKCVec_u8Z val_ref;
14770         val_ref.datalen = *((uint32_t*)val);
14771         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14772         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14773         LightningError_set_err(&this_ptr_conv, val_ref);
14774 }
14775
14776 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
14777         LDKLightningError this_ptr_conv;
14778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14779         this_ptr_conv.is_owned = false;
14780         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
14781         *ret_copy = LightningError_get_action(&this_ptr_conv);
14782         long ret_ref = (long)ret_copy;
14783         return ret_ref;
14784 }
14785
14786 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
14787         LDKLightningError this_ptr_conv;
14788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14789         this_ptr_conv.is_owned = false;
14790         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
14791         FREE((void*)val);
14792         LightningError_set_action(&this_ptr_conv, val_conv);
14793 }
14794
14795 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
14796         LDKCVec_u8Z err_arg_ref;
14797         err_arg_ref.datalen = *((uint32_t*)err_arg);
14798         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14799         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
14800         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
14801         FREE((void*)action_arg);
14802         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
14803         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14804         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14805         long ret_ref = (long)ret_var.inner;
14806         if (ret_var.is_owned) {
14807                 ret_ref |= 1;
14808         }
14809         return ret_ref;
14810 }
14811
14812 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
14813         LDKLightningError orig_conv;
14814         orig_conv.inner = (void*)(orig & (~1));
14815         orig_conv.is_owned = false;
14816         LDKLightningError ret_var = LightningError_clone(&orig_conv);
14817         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14818         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14819         long ret_ref = (long)ret_var.inner;
14820         if (ret_var.is_owned) {
14821                 ret_ref |= 1;
14822         }
14823         return ret_ref;
14824 }
14825
14826 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
14827         LDKCommitmentUpdate this_obj_conv;
14828         this_obj_conv.inner = (void*)(this_obj & (~1));
14829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14830         CommitmentUpdate_free(this_obj_conv);
14831 }
14832
14833 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
14834         LDKCommitmentUpdate this_ptr_conv;
14835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14836         this_ptr_conv.is_owned = false;
14837         LDKCVec_UpdateAddHTLCZ val_constr;
14838         val_constr.datalen = *((uint32_t*)val);
14839         if (val_constr.datalen > 0)
14840                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14841         else
14842                 val_constr.data = NULL;
14843         uint32_t* val_vals = (uint32_t*)(val + 4);
14844         for (size_t p = 0; p < val_constr.datalen; p++) {
14845                 uint32_t val_conv_15 = val_vals[p];
14846                 LDKUpdateAddHTLC val_conv_15_conv;
14847                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
14848                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
14849                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
14850                 val_constr.data[p] = val_conv_15_conv;
14851         }
14852         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
14853 }
14854
14855 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
14856         LDKCommitmentUpdate this_ptr_conv;
14857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14858         this_ptr_conv.is_owned = false;
14859         LDKCVec_UpdateFulfillHTLCZ val_constr;
14860         val_constr.datalen = *((uint32_t*)val);
14861         if (val_constr.datalen > 0)
14862                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14863         else
14864                 val_constr.data = NULL;
14865         uint32_t* val_vals = (uint32_t*)(val + 4);
14866         for (size_t t = 0; t < val_constr.datalen; t++) {
14867                 uint32_t val_conv_19 = val_vals[t];
14868                 LDKUpdateFulfillHTLC val_conv_19_conv;
14869                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
14870                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
14871                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
14872                 val_constr.data[t] = val_conv_19_conv;
14873         }
14874         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
14875 }
14876
14877 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
14878         LDKCommitmentUpdate this_ptr_conv;
14879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14880         this_ptr_conv.is_owned = false;
14881         LDKCVec_UpdateFailHTLCZ val_constr;
14882         val_constr.datalen = *((uint32_t*)val);
14883         if (val_constr.datalen > 0)
14884                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14885         else
14886                 val_constr.data = NULL;
14887         uint32_t* val_vals = (uint32_t*)(val + 4);
14888         for (size_t q = 0; q < val_constr.datalen; q++) {
14889                 uint32_t val_conv_16 = val_vals[q];
14890                 LDKUpdateFailHTLC val_conv_16_conv;
14891                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
14892                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
14893                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
14894                 val_constr.data[q] = val_conv_16_conv;
14895         }
14896         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
14897 }
14898
14899 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
14900         LDKCommitmentUpdate this_ptr_conv;
14901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14902         this_ptr_conv.is_owned = false;
14903         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
14904         val_constr.datalen = *((uint32_t*)val);
14905         if (val_constr.datalen > 0)
14906                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14907         else
14908                 val_constr.data = NULL;
14909         uint32_t* val_vals = (uint32_t*)(val + 4);
14910         for (size_t z = 0; z < val_constr.datalen; z++) {
14911                 uint32_t val_conv_25 = val_vals[z];
14912                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
14913                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
14914                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
14915                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
14916                 val_constr.data[z] = val_conv_25_conv;
14917         }
14918         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
14919 }
14920
14921 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
14922         LDKCommitmentUpdate this_ptr_conv;
14923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14924         this_ptr_conv.is_owned = false;
14925         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
14926         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14927         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14928         long ret_ref = (long)ret_var.inner;
14929         if (ret_var.is_owned) {
14930                 ret_ref |= 1;
14931         }
14932         return ret_ref;
14933 }
14934
14935 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
14936         LDKCommitmentUpdate this_ptr_conv;
14937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14938         this_ptr_conv.is_owned = false;
14939         LDKUpdateFee val_conv;
14940         val_conv.inner = (void*)(val & (~1));
14941         val_conv.is_owned = (val & 1) || (val == 0);
14942         val_conv = UpdateFee_clone(&val_conv);
14943         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
14944 }
14945
14946 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
14947         LDKCommitmentUpdate this_ptr_conv;
14948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14949         this_ptr_conv.is_owned = false;
14950         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
14951         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14952         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14953         long ret_ref = (long)ret_var.inner;
14954         if (ret_var.is_owned) {
14955                 ret_ref |= 1;
14956         }
14957         return ret_ref;
14958 }
14959
14960 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
14961         LDKCommitmentUpdate this_ptr_conv;
14962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14963         this_ptr_conv.is_owned = false;
14964         LDKCommitmentSigned val_conv;
14965         val_conv.inner = (void*)(val & (~1));
14966         val_conv.is_owned = (val & 1) || (val == 0);
14967         val_conv = CommitmentSigned_clone(&val_conv);
14968         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
14969 }
14970
14971 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) {
14972         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
14973         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
14974         if (update_add_htlcs_arg_constr.datalen > 0)
14975                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14976         else
14977                 update_add_htlcs_arg_constr.data = NULL;
14978         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
14979         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
14980                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
14981                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
14982                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
14983                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
14984                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
14985                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
14986         }
14987         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
14988         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
14989         if (update_fulfill_htlcs_arg_constr.datalen > 0)
14990                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14991         else
14992                 update_fulfill_htlcs_arg_constr.data = NULL;
14993         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
14994         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
14995                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
14996                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
14997                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
14998                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
14999                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
15000                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
15001         }
15002         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
15003         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
15004         if (update_fail_htlcs_arg_constr.datalen > 0)
15005                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
15006         else
15007                 update_fail_htlcs_arg_constr.data = NULL;
15008         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
15009         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
15010                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
15011                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
15012                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
15013                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
15014                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
15015                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
15016         }
15017         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
15018         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
15019         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
15020                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
15021         else
15022                 update_fail_malformed_htlcs_arg_constr.data = NULL;
15023         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
15024         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
15025                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
15026                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
15027                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
15028                 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);
15029                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
15030                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
15031         }
15032         LDKUpdateFee update_fee_arg_conv;
15033         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
15034         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
15035         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
15036         LDKCommitmentSigned commitment_signed_arg_conv;
15037         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
15038         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
15039         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
15040         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);
15041         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15042         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15043         long ret_ref = (long)ret_var.inner;
15044         if (ret_var.is_owned) {
15045                 ret_ref |= 1;
15046         }
15047         return ret_ref;
15048 }
15049
15050 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
15051         LDKCommitmentUpdate orig_conv;
15052         orig_conv.inner = (void*)(orig & (~1));
15053         orig_conv.is_owned = false;
15054         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
15055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15057         long ret_ref = (long)ret_var.inner;
15058         if (ret_var.is_owned) {
15059                 ret_ref |= 1;
15060         }
15061         return ret_ref;
15062 }
15063
15064 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
15065         if ((this_ptr & 1) != 0) return;
15066         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
15067         FREE((void*)this_ptr);
15068         HTLCFailChannelUpdate_free(this_ptr_conv);
15069 }
15070
15071 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
15072         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
15073         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
15074         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
15075         long ret_ref = (long)ret_copy;
15076         return ret_ref;
15077 }
15078
15079 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
15080         if ((this_ptr & 1) != 0) return;
15081         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
15082         FREE((void*)this_ptr);
15083         ChannelMessageHandler_free(this_ptr_conv);
15084 }
15085
15086 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
15087         if ((this_ptr & 1) != 0) return;
15088         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
15089         FREE((void*)this_ptr);
15090         RoutingMessageHandler_free(this_ptr_conv);
15091 }
15092
15093 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
15094         LDKAcceptChannel obj_conv;
15095         obj_conv.inner = (void*)(obj & (~1));
15096         obj_conv.is_owned = false;
15097         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
15098         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15099         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15100         CVec_u8Z_free(ret_var);
15101         return ret_arr;
15102 }
15103
15104 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
15105         LDKu8slice ser_ref;
15106         ser_ref.datalen = *((uint32_t*)ser);
15107         ser_ref.data = (int8_t*)(ser + 4);
15108         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
15109         *ret_conv = AcceptChannel_read(ser_ref);
15110         return (long)ret_conv;
15111 }
15112
15113 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
15114         LDKAnnouncementSignatures obj_conv;
15115         obj_conv.inner = (void*)(obj & (~1));
15116         obj_conv.is_owned = false;
15117         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
15118         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15119         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15120         CVec_u8Z_free(ret_var);
15121         return ret_arr;
15122 }
15123
15124 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
15125         LDKu8slice ser_ref;
15126         ser_ref.datalen = *((uint32_t*)ser);
15127         ser_ref.data = (int8_t*)(ser + 4);
15128         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
15129         *ret_conv = AnnouncementSignatures_read(ser_ref);
15130         return (long)ret_conv;
15131 }
15132
15133 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
15134         LDKChannelReestablish obj_conv;
15135         obj_conv.inner = (void*)(obj & (~1));
15136         obj_conv.is_owned = false;
15137         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
15138         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15139         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15140         CVec_u8Z_free(ret_var);
15141         return ret_arr;
15142 }
15143
15144 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
15145         LDKu8slice ser_ref;
15146         ser_ref.datalen = *((uint32_t*)ser);
15147         ser_ref.data = (int8_t*)(ser + 4);
15148         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
15149         *ret_conv = ChannelReestablish_read(ser_ref);
15150         return (long)ret_conv;
15151 }
15152
15153 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
15154         LDKClosingSigned obj_conv;
15155         obj_conv.inner = (void*)(obj & (~1));
15156         obj_conv.is_owned = false;
15157         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
15158         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15159         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15160         CVec_u8Z_free(ret_var);
15161         return ret_arr;
15162 }
15163
15164 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
15165         LDKu8slice ser_ref;
15166         ser_ref.datalen = *((uint32_t*)ser);
15167         ser_ref.data = (int8_t*)(ser + 4);
15168         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
15169         *ret_conv = ClosingSigned_read(ser_ref);
15170         return (long)ret_conv;
15171 }
15172
15173 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
15174         LDKCommitmentSigned obj_conv;
15175         obj_conv.inner = (void*)(obj & (~1));
15176         obj_conv.is_owned = false;
15177         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
15178         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15179         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15180         CVec_u8Z_free(ret_var);
15181         return ret_arr;
15182 }
15183
15184 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
15185         LDKu8slice ser_ref;
15186         ser_ref.datalen = *((uint32_t*)ser);
15187         ser_ref.data = (int8_t*)(ser + 4);
15188         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
15189         *ret_conv = CommitmentSigned_read(ser_ref);
15190         return (long)ret_conv;
15191 }
15192
15193 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
15194         LDKFundingCreated obj_conv;
15195         obj_conv.inner = (void*)(obj & (~1));
15196         obj_conv.is_owned = false;
15197         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
15198         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15199         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15200         CVec_u8Z_free(ret_var);
15201         return ret_arr;
15202 }
15203
15204 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
15205         LDKu8slice ser_ref;
15206         ser_ref.datalen = *((uint32_t*)ser);
15207         ser_ref.data = (int8_t*)(ser + 4);
15208         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
15209         *ret_conv = FundingCreated_read(ser_ref);
15210         return (long)ret_conv;
15211 }
15212
15213 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
15214         LDKFundingSigned obj_conv;
15215         obj_conv.inner = (void*)(obj & (~1));
15216         obj_conv.is_owned = false;
15217         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
15218         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15219         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15220         CVec_u8Z_free(ret_var);
15221         return ret_arr;
15222 }
15223
15224 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
15225         LDKu8slice ser_ref;
15226         ser_ref.datalen = *((uint32_t*)ser);
15227         ser_ref.data = (int8_t*)(ser + 4);
15228         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15229         *ret_conv = FundingSigned_read(ser_ref);
15230         return (long)ret_conv;
15231 }
15232
15233 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
15234         LDKFundingLocked obj_conv;
15235         obj_conv.inner = (void*)(obj & (~1));
15236         obj_conv.is_owned = false;
15237         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
15238         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15239         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15240         CVec_u8Z_free(ret_var);
15241         return ret_arr;
15242 }
15243
15244 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
15245         LDKu8slice ser_ref;
15246         ser_ref.datalen = *((uint32_t*)ser);
15247         ser_ref.data = (int8_t*)(ser + 4);
15248         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15249         *ret_conv = FundingLocked_read(ser_ref);
15250         return (long)ret_conv;
15251 }
15252
15253 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
15254         LDKInit obj_conv;
15255         obj_conv.inner = (void*)(obj & (~1));
15256         obj_conv.is_owned = false;
15257         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
15258         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15259         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15260         CVec_u8Z_free(ret_var);
15261         return ret_arr;
15262 }
15263
15264 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
15265         LDKu8slice ser_ref;
15266         ser_ref.datalen = *((uint32_t*)ser);
15267         ser_ref.data = (int8_t*)(ser + 4);
15268         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15269         *ret_conv = Init_read(ser_ref);
15270         return (long)ret_conv;
15271 }
15272
15273 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
15274         LDKOpenChannel obj_conv;
15275         obj_conv.inner = (void*)(obj & (~1));
15276         obj_conv.is_owned = false;
15277         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
15278         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15279         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15280         CVec_u8Z_free(ret_var);
15281         return ret_arr;
15282 }
15283
15284 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
15285         LDKu8slice ser_ref;
15286         ser_ref.datalen = *((uint32_t*)ser);
15287         ser_ref.data = (int8_t*)(ser + 4);
15288         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15289         *ret_conv = OpenChannel_read(ser_ref);
15290         return (long)ret_conv;
15291 }
15292
15293 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
15294         LDKRevokeAndACK obj_conv;
15295         obj_conv.inner = (void*)(obj & (~1));
15296         obj_conv.is_owned = false;
15297         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
15298         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15299         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15300         CVec_u8Z_free(ret_var);
15301         return ret_arr;
15302 }
15303
15304 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
15305         LDKu8slice ser_ref;
15306         ser_ref.datalen = *((uint32_t*)ser);
15307         ser_ref.data = (int8_t*)(ser + 4);
15308         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15309         *ret_conv = RevokeAndACK_read(ser_ref);
15310         return (long)ret_conv;
15311 }
15312
15313 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
15314         LDKShutdown obj_conv;
15315         obj_conv.inner = (void*)(obj & (~1));
15316         obj_conv.is_owned = false;
15317         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
15318         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15319         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15320         CVec_u8Z_free(ret_var);
15321         return ret_arr;
15322 }
15323
15324 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
15325         LDKu8slice ser_ref;
15326         ser_ref.datalen = *((uint32_t*)ser);
15327         ser_ref.data = (int8_t*)(ser + 4);
15328         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15329         *ret_conv = Shutdown_read(ser_ref);
15330         return (long)ret_conv;
15331 }
15332
15333 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
15334         LDKUpdateFailHTLC obj_conv;
15335         obj_conv.inner = (void*)(obj & (~1));
15336         obj_conv.is_owned = false;
15337         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
15338         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15339         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15340         CVec_u8Z_free(ret_var);
15341         return ret_arr;
15342 }
15343
15344 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
15345         LDKu8slice ser_ref;
15346         ser_ref.datalen = *((uint32_t*)ser);
15347         ser_ref.data = (int8_t*)(ser + 4);
15348         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15349         *ret_conv = UpdateFailHTLC_read(ser_ref);
15350         return (long)ret_conv;
15351 }
15352
15353 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
15354         LDKUpdateFailMalformedHTLC obj_conv;
15355         obj_conv.inner = (void*)(obj & (~1));
15356         obj_conv.is_owned = false;
15357         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
15358         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15359         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15360         CVec_u8Z_free(ret_var);
15361         return ret_arr;
15362 }
15363
15364 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
15365         LDKu8slice ser_ref;
15366         ser_ref.datalen = *((uint32_t*)ser);
15367         ser_ref.data = (int8_t*)(ser + 4);
15368         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15369         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
15370         return (long)ret_conv;
15371 }
15372
15373 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
15374         LDKUpdateFee obj_conv;
15375         obj_conv.inner = (void*)(obj & (~1));
15376         obj_conv.is_owned = false;
15377         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
15378         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15379         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15380         CVec_u8Z_free(ret_var);
15381         return ret_arr;
15382 }
15383
15384 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
15385         LDKu8slice ser_ref;
15386         ser_ref.datalen = *((uint32_t*)ser);
15387         ser_ref.data = (int8_t*)(ser + 4);
15388         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15389         *ret_conv = UpdateFee_read(ser_ref);
15390         return (long)ret_conv;
15391 }
15392
15393 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
15394         LDKUpdateFulfillHTLC obj_conv;
15395         obj_conv.inner = (void*)(obj & (~1));
15396         obj_conv.is_owned = false;
15397         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
15398         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15399         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15400         CVec_u8Z_free(ret_var);
15401         return ret_arr;
15402 }
15403
15404 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
15405         LDKu8slice ser_ref;
15406         ser_ref.datalen = *((uint32_t*)ser);
15407         ser_ref.data = (int8_t*)(ser + 4);
15408         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15409         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
15410         return (long)ret_conv;
15411 }
15412
15413 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
15414         LDKUpdateAddHTLC obj_conv;
15415         obj_conv.inner = (void*)(obj & (~1));
15416         obj_conv.is_owned = false;
15417         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
15418         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15419         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15420         CVec_u8Z_free(ret_var);
15421         return ret_arr;
15422 }
15423
15424 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
15425         LDKu8slice ser_ref;
15426         ser_ref.datalen = *((uint32_t*)ser);
15427         ser_ref.data = (int8_t*)(ser + 4);
15428         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15429         *ret_conv = UpdateAddHTLC_read(ser_ref);
15430         return (long)ret_conv;
15431 }
15432
15433 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
15434         LDKPing obj_conv;
15435         obj_conv.inner = (void*)(obj & (~1));
15436         obj_conv.is_owned = false;
15437         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
15438         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15439         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15440         CVec_u8Z_free(ret_var);
15441         return ret_arr;
15442 }
15443
15444 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
15445         LDKu8slice ser_ref;
15446         ser_ref.datalen = *((uint32_t*)ser);
15447         ser_ref.data = (int8_t*)(ser + 4);
15448         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15449         *ret_conv = Ping_read(ser_ref);
15450         return (long)ret_conv;
15451 }
15452
15453 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
15454         LDKPong obj_conv;
15455         obj_conv.inner = (void*)(obj & (~1));
15456         obj_conv.is_owned = false;
15457         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
15458         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15459         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15460         CVec_u8Z_free(ret_var);
15461         return ret_arr;
15462 }
15463
15464 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
15465         LDKu8slice ser_ref;
15466         ser_ref.datalen = *((uint32_t*)ser);
15467         ser_ref.data = (int8_t*)(ser + 4);
15468         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15469         *ret_conv = Pong_read(ser_ref);
15470         return (long)ret_conv;
15471 }
15472
15473 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
15474         LDKUnsignedChannelAnnouncement obj_conv;
15475         obj_conv.inner = (void*)(obj & (~1));
15476         obj_conv.is_owned = false;
15477         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
15478         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15479         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15480         CVec_u8Z_free(ret_var);
15481         return ret_arr;
15482 }
15483
15484 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
15485         LDKu8slice ser_ref;
15486         ser_ref.datalen = *((uint32_t*)ser);
15487         ser_ref.data = (int8_t*)(ser + 4);
15488         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15489         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
15490         return (long)ret_conv;
15491 }
15492
15493 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
15494         LDKChannelAnnouncement obj_conv;
15495         obj_conv.inner = (void*)(obj & (~1));
15496         obj_conv.is_owned = false;
15497         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
15498         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15499         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15500         CVec_u8Z_free(ret_var);
15501         return ret_arr;
15502 }
15503
15504 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
15505         LDKu8slice ser_ref;
15506         ser_ref.datalen = *((uint32_t*)ser);
15507         ser_ref.data = (int8_t*)(ser + 4);
15508         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15509         *ret_conv = ChannelAnnouncement_read(ser_ref);
15510         return (long)ret_conv;
15511 }
15512
15513 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
15514         LDKUnsignedChannelUpdate obj_conv;
15515         obj_conv.inner = (void*)(obj & (~1));
15516         obj_conv.is_owned = false;
15517         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
15518         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15519         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15520         CVec_u8Z_free(ret_var);
15521         return ret_arr;
15522 }
15523
15524 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
15525         LDKu8slice ser_ref;
15526         ser_ref.datalen = *((uint32_t*)ser);
15527         ser_ref.data = (int8_t*)(ser + 4);
15528         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15529         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
15530         return (long)ret_conv;
15531 }
15532
15533 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
15534         LDKChannelUpdate obj_conv;
15535         obj_conv.inner = (void*)(obj & (~1));
15536         obj_conv.is_owned = false;
15537         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
15538         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15539         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15540         CVec_u8Z_free(ret_var);
15541         return ret_arr;
15542 }
15543
15544 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
15545         LDKu8slice ser_ref;
15546         ser_ref.datalen = *((uint32_t*)ser);
15547         ser_ref.data = (int8_t*)(ser + 4);
15548         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15549         *ret_conv = ChannelUpdate_read(ser_ref);
15550         return (long)ret_conv;
15551 }
15552
15553 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
15554         LDKErrorMessage obj_conv;
15555         obj_conv.inner = (void*)(obj & (~1));
15556         obj_conv.is_owned = false;
15557         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
15558         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15559         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15560         CVec_u8Z_free(ret_var);
15561         return ret_arr;
15562 }
15563
15564 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
15565         LDKu8slice ser_ref;
15566         ser_ref.datalen = *((uint32_t*)ser);
15567         ser_ref.data = (int8_t*)(ser + 4);
15568         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15569         *ret_conv = ErrorMessage_read(ser_ref);
15570         return (long)ret_conv;
15571 }
15572
15573 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
15574         LDKUnsignedNodeAnnouncement obj_conv;
15575         obj_conv.inner = (void*)(obj & (~1));
15576         obj_conv.is_owned = false;
15577         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
15578         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15579         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15580         CVec_u8Z_free(ret_var);
15581         return ret_arr;
15582 }
15583
15584 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
15585         LDKu8slice ser_ref;
15586         ser_ref.datalen = *((uint32_t*)ser);
15587         ser_ref.data = (int8_t*)(ser + 4);
15588         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15589         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
15590         return (long)ret_conv;
15591 }
15592
15593 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
15594         LDKNodeAnnouncement obj_conv;
15595         obj_conv.inner = (void*)(obj & (~1));
15596         obj_conv.is_owned = false;
15597         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
15598         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15599         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15600         CVec_u8Z_free(ret_var);
15601         return ret_arr;
15602 }
15603
15604 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
15605         LDKu8slice ser_ref;
15606         ser_ref.datalen = *((uint32_t*)ser);
15607         ser_ref.data = (int8_t*)(ser + 4);
15608         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15609         *ret_conv = NodeAnnouncement_read(ser_ref);
15610         return (long)ret_conv;
15611 }
15612
15613 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
15614         LDKu8slice ser_ref;
15615         ser_ref.datalen = *((uint32_t*)ser);
15616         ser_ref.data = (int8_t*)(ser + 4);
15617         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15618         *ret_conv = QueryShortChannelIds_read(ser_ref);
15619         return (long)ret_conv;
15620 }
15621
15622 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
15623         LDKQueryShortChannelIds obj_conv;
15624         obj_conv.inner = (void*)(obj & (~1));
15625         obj_conv.is_owned = false;
15626         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
15627         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15628         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15629         CVec_u8Z_free(ret_var);
15630         return ret_arr;
15631 }
15632
15633 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
15634         LDKu8slice ser_ref;
15635         ser_ref.datalen = *((uint32_t*)ser);
15636         ser_ref.data = (int8_t*)(ser + 4);
15637         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15638         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
15639         return (long)ret_conv;
15640 }
15641
15642 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
15643         LDKReplyShortChannelIdsEnd obj_conv;
15644         obj_conv.inner = (void*)(obj & (~1));
15645         obj_conv.is_owned = false;
15646         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
15647         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15648         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15649         CVec_u8Z_free(ret_var);
15650         return ret_arr;
15651 }
15652
15653 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
15654         LDKu8slice ser_ref;
15655         ser_ref.datalen = *((uint32_t*)ser);
15656         ser_ref.data = (int8_t*)(ser + 4);
15657         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15658         *ret_conv = QueryChannelRange_read(ser_ref);
15659         return (long)ret_conv;
15660 }
15661
15662 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
15663         LDKQueryChannelRange obj_conv;
15664         obj_conv.inner = (void*)(obj & (~1));
15665         obj_conv.is_owned = false;
15666         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
15667         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15668         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15669         CVec_u8Z_free(ret_var);
15670         return ret_arr;
15671 }
15672
15673 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
15674         LDKu8slice ser_ref;
15675         ser_ref.datalen = *((uint32_t*)ser);
15676         ser_ref.data = (int8_t*)(ser + 4);
15677         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15678         *ret_conv = ReplyChannelRange_read(ser_ref);
15679         return (long)ret_conv;
15680 }
15681
15682 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
15683         LDKReplyChannelRange obj_conv;
15684         obj_conv.inner = (void*)(obj & (~1));
15685         obj_conv.is_owned = false;
15686         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
15687         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15688         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15689         CVec_u8Z_free(ret_var);
15690         return ret_arr;
15691 }
15692
15693 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
15694         LDKu8slice ser_ref;
15695         ser_ref.datalen = *((uint32_t*)ser);
15696         ser_ref.data = (int8_t*)(ser + 4);
15697         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15698         *ret_conv = GossipTimestampFilter_read(ser_ref);
15699         return (long)ret_conv;
15700 }
15701
15702 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
15703         LDKGossipTimestampFilter obj_conv;
15704         obj_conv.inner = (void*)(obj & (~1));
15705         obj_conv.is_owned = false;
15706         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
15707         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15708         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
15709         CVec_u8Z_free(ret_var);
15710         return ret_arr;
15711 }
15712
15713 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
15714         LDKIgnoringMessageHandler this_obj_conv;
15715         this_obj_conv.inner = (void*)(this_obj & (~1));
15716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15717         IgnoringMessageHandler_free(this_obj_conv);
15718 }
15719
15720 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
15721         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
15722         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15723         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15724         long ret_ref = (long)ret_var.inner;
15725         if (ret_var.is_owned) {
15726                 ret_ref |= 1;
15727         }
15728         return ret_ref;
15729 }
15730
15731 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
15732         LDKIgnoringMessageHandler this_arg_conv;
15733         this_arg_conv.inner = (void*)(this_arg & (~1));
15734         this_arg_conv.is_owned = false;
15735         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15736         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
15737         return (long)ret;
15738 }
15739
15740 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
15741         LDKIgnoringMessageHandler this_arg_conv;
15742         this_arg_conv.inner = (void*)(this_arg & (~1));
15743         this_arg_conv.is_owned = false;
15744         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
15745         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
15746         return (long)ret;
15747 }
15748
15749 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
15750         LDKErroringMessageHandler this_obj_conv;
15751         this_obj_conv.inner = (void*)(this_obj & (~1));
15752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15753         ErroringMessageHandler_free(this_obj_conv);
15754 }
15755
15756 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
15757         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
15758         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15759         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15760         long ret_ref = (long)ret_var.inner;
15761         if (ret_var.is_owned) {
15762                 ret_ref |= 1;
15763         }
15764         return ret_ref;
15765 }
15766
15767 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
15768         LDKErroringMessageHandler this_arg_conv;
15769         this_arg_conv.inner = (void*)(this_arg & (~1));
15770         this_arg_conv.is_owned = false;
15771         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15772         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
15773         return (long)ret;
15774 }
15775
15776 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
15777         LDKErroringMessageHandler this_arg_conv;
15778         this_arg_conv.inner = (void*)(this_arg & (~1));
15779         this_arg_conv.is_owned = false;
15780         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
15781         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
15782         return (long)ret;
15783 }
15784
15785 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
15786         LDKMessageHandler this_obj_conv;
15787         this_obj_conv.inner = (void*)(this_obj & (~1));
15788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15789         MessageHandler_free(this_obj_conv);
15790 }
15791
15792 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
15793         LDKMessageHandler this_ptr_conv;
15794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15795         this_ptr_conv.is_owned = false;
15796         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
15797         return ret_ret;
15798 }
15799
15800 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
15801         LDKMessageHandler this_ptr_conv;
15802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15803         this_ptr_conv.is_owned = false;
15804         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
15805         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
15806 }
15807
15808 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
15809         LDKMessageHandler this_ptr_conv;
15810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15811         this_ptr_conv.is_owned = false;
15812         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
15813         return ret_ret;
15814 }
15815
15816 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
15817         LDKMessageHandler this_ptr_conv;
15818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15819         this_ptr_conv.is_owned = false;
15820         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
15821         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
15822 }
15823
15824 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
15825         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
15826         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
15827         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
15828         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15829         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15830         long ret_ref = (long)ret_var.inner;
15831         if (ret_var.is_owned) {
15832                 ret_ref |= 1;
15833         }
15834         return ret_ref;
15835 }
15836
15837 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
15838         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
15839         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
15840         *ret = SocketDescriptor_clone(orig_conv);
15841         return (long)ret;
15842 }
15843
15844 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
15845         if ((this_ptr & 1) != 0) return;
15846         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
15847         FREE((void*)this_ptr);
15848         SocketDescriptor_free(this_ptr_conv);
15849 }
15850
15851 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
15852         LDKPeerHandleError this_obj_conv;
15853         this_obj_conv.inner = (void*)(this_obj & (~1));
15854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15855         PeerHandleError_free(this_obj_conv);
15856 }
15857
15858 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
15859         LDKPeerHandleError this_ptr_conv;
15860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15861         this_ptr_conv.is_owned = false;
15862         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
15863         return ret_val;
15864 }
15865
15866 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
15867         LDKPeerHandleError this_ptr_conv;
15868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15869         this_ptr_conv.is_owned = false;
15870         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
15871 }
15872
15873 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
15874         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
15875         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15876         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15877         long ret_ref = (long)ret_var.inner;
15878         if (ret_var.is_owned) {
15879                 ret_ref |= 1;
15880         }
15881         return ret_ref;
15882 }
15883
15884 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
15885         LDKPeerHandleError orig_conv;
15886         orig_conv.inner = (void*)(orig & (~1));
15887         orig_conv.is_owned = false;
15888         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
15889         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15890         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15891         long ret_ref = (long)ret_var.inner;
15892         if (ret_var.is_owned) {
15893                 ret_ref |= 1;
15894         }
15895         return ret_ref;
15896 }
15897
15898 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
15899         LDKPeerManager this_obj_conv;
15900         this_obj_conv.inner = (void*)(this_obj & (~1));
15901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15902         PeerManager_free(this_obj_conv);
15903 }
15904
15905 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) {
15906         LDKMessageHandler message_handler_conv;
15907         message_handler_conv.inner = (void*)(message_handler & (~1));
15908         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
15909         // Warning: we need a move here but no clone is available for LDKMessageHandler
15910         LDKSecretKey our_node_secret_ref;
15911         CHECK(*((uint32_t*)our_node_secret) == 32);
15912         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
15913         unsigned char ephemeral_random_data_arr[32];
15914         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
15915         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
15916         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
15917         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15918         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
15919         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15920         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15921         long ret_ref = (long)ret_var.inner;
15922         if (ret_var.is_owned) {
15923                 ret_ref |= 1;
15924         }
15925         return ret_ref;
15926 }
15927
15928 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
15929         LDKPeerManager this_arg_conv;
15930         this_arg_conv.inner = (void*)(this_arg & (~1));
15931         this_arg_conv.is_owned = false;
15932         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
15933         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
15934         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
15935         for (size_t m = 0; m < ret_var.datalen; m++) {
15936                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15937                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
15938                 ret_arr_ptr[m] = ret_conv_12_arr;
15939         }
15940         FREE(ret_var.data);
15941         return ret_arr;
15942 }
15943
15944 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
15945         LDKPeerManager this_arg_conv;
15946         this_arg_conv.inner = (void*)(this_arg & (~1));
15947         this_arg_conv.is_owned = false;
15948         LDKPublicKey their_node_id_ref;
15949         CHECK(*((uint32_t*)their_node_id) == 33);
15950         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
15951         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15952         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
15953         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
15954         return (long)ret_conv;
15955 }
15956
15957 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
15958         LDKPeerManager this_arg_conv;
15959         this_arg_conv.inner = (void*)(this_arg & (~1));
15960         this_arg_conv.is_owned = false;
15961         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15962         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15963         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
15964         return (long)ret_conv;
15965 }
15966
15967 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
15968         LDKPeerManager this_arg_conv;
15969         this_arg_conv.inner = (void*)(this_arg & (~1));
15970         this_arg_conv.is_owned = false;
15971         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
15972         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
15973         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
15974         return (long)ret_conv;
15975 }
15976
15977 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
15978         LDKPeerManager this_arg_conv;
15979         this_arg_conv.inner = (void*)(this_arg & (~1));
15980         this_arg_conv.is_owned = false;
15981         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
15982         LDKu8slice data_ref;
15983         data_ref.datalen = *((uint32_t*)data);
15984         data_ref.data = (int8_t*)(data + 4);
15985         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
15986         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
15987         return (long)ret_conv;
15988 }
15989
15990 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
15991         LDKPeerManager this_arg_conv;
15992         this_arg_conv.inner = (void*)(this_arg & (~1));
15993         this_arg_conv.is_owned = false;
15994         PeerManager_process_events(&this_arg_conv);
15995 }
15996
15997 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
15998         LDKPeerManager this_arg_conv;
15999         this_arg_conv.inner = (void*)(this_arg & (~1));
16000         this_arg_conv.is_owned = false;
16001         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
16002         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
16003 }
16004
16005 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
16006         LDKPeerManager this_arg_conv;
16007         this_arg_conv.inner = (void*)(this_arg & (~1));
16008         this_arg_conv.is_owned = false;
16009         LDKPublicKey node_id_ref;
16010         CHECK(*((uint32_t*)node_id) == 33);
16011         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16012         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
16013 }
16014
16015 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
16016         LDKPeerManager this_arg_conv;
16017         this_arg_conv.inner = (void*)(this_arg & (~1));
16018         this_arg_conv.is_owned = false;
16019         PeerManager_timer_tick_occurred(&this_arg_conv);
16020 }
16021
16022 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
16023         unsigned char commitment_seed_arr[32];
16024         CHECK(*((uint32_t*)commitment_seed) == 32);
16025         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
16026         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
16027         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16028         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
16029         return ret_arr;
16030 }
16031
16032 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
16033         LDKPublicKey per_commitment_point_ref;
16034         CHECK(*((uint32_t*)per_commitment_point) == 33);
16035         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16036         unsigned char base_secret_arr[32];
16037         CHECK(*((uint32_t*)base_secret) == 32);
16038         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
16039         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
16040         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16041         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
16042         return (long)ret_conv;
16043 }
16044
16045 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
16046         LDKPublicKey per_commitment_point_ref;
16047         CHECK(*((uint32_t*)per_commitment_point) == 33);
16048         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16049         LDKPublicKey base_point_ref;
16050         CHECK(*((uint32_t*)base_point) == 33);
16051         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
16052         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16053         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
16054         return (long)ret_conv;
16055 }
16056
16057 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
16058         unsigned char per_commitment_secret_arr[32];
16059         CHECK(*((uint32_t*)per_commitment_secret) == 32);
16060         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
16061         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
16062         unsigned char countersignatory_revocation_base_secret_arr[32];
16063         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
16064         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
16065         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
16066         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
16067         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
16068         return (long)ret_conv;
16069 }
16070
16071 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
16072         LDKPublicKey per_commitment_point_ref;
16073         CHECK(*((uint32_t*)per_commitment_point) == 33);
16074         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16075         LDKPublicKey countersignatory_revocation_base_point_ref;
16076         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
16077         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
16078         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16079         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
16080         return (long)ret_conv;
16081 }
16082
16083 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
16084         LDKTxCreationKeys this_obj_conv;
16085         this_obj_conv.inner = (void*)(this_obj & (~1));
16086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16087         TxCreationKeys_free(this_obj_conv);
16088 }
16089
16090 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
16091         LDKTxCreationKeys this_ptr_conv;
16092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16093         this_ptr_conv.is_owned = false;
16094         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16095         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16096         return ret_arr;
16097 }
16098
16099 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16100         LDKTxCreationKeys this_ptr_conv;
16101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16102         this_ptr_conv.is_owned = false;
16103         LDKPublicKey val_ref;
16104         CHECK(*((uint32_t*)val) == 33);
16105         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16106         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
16107 }
16108
16109 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
16110         LDKTxCreationKeys this_ptr_conv;
16111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16112         this_ptr_conv.is_owned = false;
16113         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16114         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
16115         return ret_arr;
16116 }
16117
16118 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
16119         LDKTxCreationKeys this_ptr_conv;
16120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16121         this_ptr_conv.is_owned = false;
16122         LDKPublicKey val_ref;
16123         CHECK(*((uint32_t*)val) == 33);
16124         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16125         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
16126 }
16127
16128 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
16129         LDKTxCreationKeys this_ptr_conv;
16130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16131         this_ptr_conv.is_owned = false;
16132         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16133         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
16134         return ret_arr;
16135 }
16136
16137 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
16138         LDKTxCreationKeys this_ptr_conv;
16139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16140         this_ptr_conv.is_owned = false;
16141         LDKPublicKey val_ref;
16142         CHECK(*((uint32_t*)val) == 33);
16143         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16144         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
16145 }
16146
16147 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
16148         LDKTxCreationKeys this_ptr_conv;
16149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16150         this_ptr_conv.is_owned = false;
16151         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16152         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
16153         return ret_arr;
16154 }
16155
16156 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
16157         LDKTxCreationKeys this_ptr_conv;
16158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16159         this_ptr_conv.is_owned = false;
16160         LDKPublicKey val_ref;
16161         CHECK(*((uint32_t*)val) == 33);
16162         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16163         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
16164 }
16165
16166 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
16167         LDKTxCreationKeys this_ptr_conv;
16168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16169         this_ptr_conv.is_owned = false;
16170         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16171         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
16172         return ret_arr;
16173 }
16174
16175 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
16176         LDKTxCreationKeys this_ptr_conv;
16177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16178         this_ptr_conv.is_owned = false;
16179         LDKPublicKey val_ref;
16180         CHECK(*((uint32_t*)val) == 33);
16181         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16182         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
16183 }
16184
16185 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) {
16186         LDKPublicKey per_commitment_point_arg_ref;
16187         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
16188         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
16189         LDKPublicKey revocation_key_arg_ref;
16190         CHECK(*((uint32_t*)revocation_key_arg) == 33);
16191         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
16192         LDKPublicKey broadcaster_htlc_key_arg_ref;
16193         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
16194         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
16195         LDKPublicKey countersignatory_htlc_key_arg_ref;
16196         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
16197         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
16198         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
16199         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
16200         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
16201         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);
16202         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16203         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16204         long ret_ref = (long)ret_var.inner;
16205         if (ret_var.is_owned) {
16206                 ret_ref |= 1;
16207         }
16208         return ret_ref;
16209 }
16210
16211 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
16212         LDKTxCreationKeys orig_conv;
16213         orig_conv.inner = (void*)(orig & (~1));
16214         orig_conv.is_owned = false;
16215         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
16216         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16217         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16218         long ret_ref = (long)ret_var.inner;
16219         if (ret_var.is_owned) {
16220                 ret_ref |= 1;
16221         }
16222         return ret_ref;
16223 }
16224
16225 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
16226         LDKTxCreationKeys obj_conv;
16227         obj_conv.inner = (void*)(obj & (~1));
16228         obj_conv.is_owned = false;
16229         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
16230         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16231         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16232         CVec_u8Z_free(ret_var);
16233         return ret_arr;
16234 }
16235
16236 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
16237         LDKu8slice ser_ref;
16238         ser_ref.datalen = *((uint32_t*)ser);
16239         ser_ref.data = (int8_t*)(ser + 4);
16240         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16241         *ret_conv = TxCreationKeys_read(ser_ref);
16242         return (long)ret_conv;
16243 }
16244
16245 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
16246         LDKChannelPublicKeys this_obj_conv;
16247         this_obj_conv.inner = (void*)(this_obj & (~1));
16248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16249         ChannelPublicKeys_free(this_obj_conv);
16250 }
16251
16252 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
16253         LDKChannelPublicKeys this_ptr_conv;
16254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16255         this_ptr_conv.is_owned = false;
16256         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16257         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16258         return ret_arr;
16259 }
16260
16261 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16262         LDKChannelPublicKeys this_ptr_conv;
16263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16264         this_ptr_conv.is_owned = false;
16265         LDKPublicKey val_ref;
16266         CHECK(*((uint32_t*)val) == 33);
16267         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16268         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
16269 }
16270
16271 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
16272         LDKChannelPublicKeys this_ptr_conv;
16273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16274         this_ptr_conv.is_owned = false;
16275         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16276         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16277         return ret_arr;
16278 }
16279
16280 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16281         LDKChannelPublicKeys this_ptr_conv;
16282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16283         this_ptr_conv.is_owned = false;
16284         LDKPublicKey val_ref;
16285         CHECK(*((uint32_t*)val) == 33);
16286         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16287         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
16288 }
16289
16290 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
16291         LDKChannelPublicKeys this_ptr_conv;
16292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16293         this_ptr_conv.is_owned = false;
16294         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16295         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
16296         return ret_arr;
16297 }
16298
16299 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16300         LDKChannelPublicKeys this_ptr_conv;
16301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16302         this_ptr_conv.is_owned = false;
16303         LDKPublicKey val_ref;
16304         CHECK(*((uint32_t*)val) == 33);
16305         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16306         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
16307 }
16308
16309 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
16310         LDKChannelPublicKeys this_ptr_conv;
16311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16312         this_ptr_conv.is_owned = false;
16313         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16314         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16315         return ret_arr;
16316 }
16317
16318 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16319         LDKChannelPublicKeys this_ptr_conv;
16320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16321         this_ptr_conv.is_owned = false;
16322         LDKPublicKey val_ref;
16323         CHECK(*((uint32_t*)val) == 33);
16324         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16325         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16326 }
16327
16328 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
16329         LDKChannelPublicKeys this_ptr_conv;
16330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16331         this_ptr_conv.is_owned = false;
16332         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16333         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16334         return ret_arr;
16335 }
16336
16337 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16338         LDKChannelPublicKeys this_ptr_conv;
16339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16340         this_ptr_conv.is_owned = false;
16341         LDKPublicKey val_ref;
16342         CHECK(*((uint32_t*)val) == 33);
16343         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16344         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
16345 }
16346
16347 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) {
16348         LDKPublicKey funding_pubkey_arg_ref;
16349         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
16350         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
16351         LDKPublicKey revocation_basepoint_arg_ref;
16352         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
16353         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
16354         LDKPublicKey payment_point_arg_ref;
16355         CHECK(*((uint32_t*)payment_point_arg) == 33);
16356         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
16357         LDKPublicKey delayed_payment_basepoint_arg_ref;
16358         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
16359         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
16360         LDKPublicKey htlc_basepoint_arg_ref;
16361         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
16362         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
16363         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);
16364         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16365         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16366         long ret_ref = (long)ret_var.inner;
16367         if (ret_var.is_owned) {
16368                 ret_ref |= 1;
16369         }
16370         return ret_ref;
16371 }
16372
16373 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
16374         LDKChannelPublicKeys orig_conv;
16375         orig_conv.inner = (void*)(orig & (~1));
16376         orig_conv.is_owned = false;
16377         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
16378         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16379         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16380         long ret_ref = (long)ret_var.inner;
16381         if (ret_var.is_owned) {
16382                 ret_ref |= 1;
16383         }
16384         return ret_ref;
16385 }
16386
16387 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
16388         LDKChannelPublicKeys obj_conv;
16389         obj_conv.inner = (void*)(obj & (~1));
16390         obj_conv.is_owned = false;
16391         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
16392         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16393         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16394         CVec_u8Z_free(ret_var);
16395         return ret_arr;
16396 }
16397
16398 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
16399         LDKu8slice ser_ref;
16400         ser_ref.datalen = *((uint32_t*)ser);
16401         ser_ref.data = (int8_t*)(ser + 4);
16402         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16403         *ret_conv = ChannelPublicKeys_read(ser_ref);
16404         return (long)ret_conv;
16405 }
16406
16407 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) {
16408         LDKPublicKey per_commitment_point_ref;
16409         CHECK(*((uint32_t*)per_commitment_point) == 33);
16410         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16411         LDKPublicKey broadcaster_delayed_payment_base_ref;
16412         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
16413         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
16414         LDKPublicKey broadcaster_htlc_base_ref;
16415         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
16416         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
16417         LDKPublicKey countersignatory_revocation_base_ref;
16418         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
16419         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
16420         LDKPublicKey countersignatory_htlc_base_ref;
16421         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
16422         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
16423         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16424         *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);
16425         return (long)ret_conv;
16426 }
16427
16428 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
16429         LDKPublicKey per_commitment_point_ref;
16430         CHECK(*((uint32_t*)per_commitment_point) == 33);
16431         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
16432         LDKChannelPublicKeys broadcaster_keys_conv;
16433         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
16434         broadcaster_keys_conv.is_owned = false;
16435         LDKChannelPublicKeys countersignatory_keys_conv;
16436         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
16437         countersignatory_keys_conv.is_owned = false;
16438         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
16439         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
16440         return (long)ret_conv;
16441 }
16442
16443 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
16444         LDKPublicKey revocation_key_ref;
16445         CHECK(*((uint32_t*)revocation_key) == 33);
16446         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16447         LDKPublicKey broadcaster_delayed_payment_key_ref;
16448         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16449         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16450         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
16451         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16452         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16453         CVec_u8Z_free(ret_var);
16454         return ret_arr;
16455 }
16456
16457 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
16458         LDKHTLCOutputInCommitment this_obj_conv;
16459         this_obj_conv.inner = (void*)(this_obj & (~1));
16460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16461         HTLCOutputInCommitment_free(this_obj_conv);
16462 }
16463
16464 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
16465         LDKHTLCOutputInCommitment this_ptr_conv;
16466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16467         this_ptr_conv.is_owned = false;
16468         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
16469         return ret_val;
16470 }
16471
16472 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
16473         LDKHTLCOutputInCommitment this_ptr_conv;
16474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16475         this_ptr_conv.is_owned = false;
16476         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
16477 }
16478
16479 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
16480         LDKHTLCOutputInCommitment this_ptr_conv;
16481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16482         this_ptr_conv.is_owned = false;
16483         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
16484         return ret_val;
16485 }
16486
16487 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
16488         LDKHTLCOutputInCommitment this_ptr_conv;
16489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16490         this_ptr_conv.is_owned = false;
16491         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
16492 }
16493
16494 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
16495         LDKHTLCOutputInCommitment this_ptr_conv;
16496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16497         this_ptr_conv.is_owned = false;
16498         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
16499         return ret_val;
16500 }
16501
16502 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
16503         LDKHTLCOutputInCommitment this_ptr_conv;
16504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16505         this_ptr_conv.is_owned = false;
16506         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
16507 }
16508
16509 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
16510         LDKHTLCOutputInCommitment this_ptr_conv;
16511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16512         this_ptr_conv.is_owned = false;
16513         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16514         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
16515         return ret_arr;
16516 }
16517
16518 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
16519         LDKHTLCOutputInCommitment this_ptr_conv;
16520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16521         this_ptr_conv.is_owned = false;
16522         LDKThirtyTwoBytes val_ref;
16523         CHECK(*((uint32_t*)val) == 32);
16524         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16525         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
16526 }
16527
16528 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
16529         LDKHTLCOutputInCommitment orig_conv;
16530         orig_conv.inner = (void*)(orig & (~1));
16531         orig_conv.is_owned = false;
16532         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
16533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16535         long ret_ref = (long)ret_var.inner;
16536         if (ret_var.is_owned) {
16537                 ret_ref |= 1;
16538         }
16539         return ret_ref;
16540 }
16541
16542 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
16543         LDKHTLCOutputInCommitment obj_conv;
16544         obj_conv.inner = (void*)(obj & (~1));
16545         obj_conv.is_owned = false;
16546         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
16547         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16548         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16549         CVec_u8Z_free(ret_var);
16550         return ret_arr;
16551 }
16552
16553 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
16554         LDKu8slice ser_ref;
16555         ser_ref.datalen = *((uint32_t*)ser);
16556         ser_ref.data = (int8_t*)(ser + 4);
16557         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16558         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
16559         return (long)ret_conv;
16560 }
16561
16562 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
16563         LDKHTLCOutputInCommitment htlc_conv;
16564         htlc_conv.inner = (void*)(htlc & (~1));
16565         htlc_conv.is_owned = false;
16566         LDKTxCreationKeys keys_conv;
16567         keys_conv.inner = (void*)(keys & (~1));
16568         keys_conv.is_owned = false;
16569         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
16570         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16571         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16572         CVec_u8Z_free(ret_var);
16573         return ret_arr;
16574 }
16575
16576 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
16577         LDKPublicKey broadcaster_ref;
16578         CHECK(*((uint32_t*)broadcaster) == 33);
16579         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
16580         LDKPublicKey countersignatory_ref;
16581         CHECK(*((uint32_t*)countersignatory) == 33);
16582         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
16583         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
16584         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16585         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16586         CVec_u8Z_free(ret_var);
16587         return ret_arr;
16588 }
16589
16590 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) {
16591         unsigned char prev_hash_arr[32];
16592         CHECK(*((uint32_t*)prev_hash) == 32);
16593         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
16594         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
16595         LDKHTLCOutputInCommitment htlc_conv;
16596         htlc_conv.inner = (void*)(htlc & (~1));
16597         htlc_conv.is_owned = false;
16598         LDKPublicKey broadcaster_delayed_payment_key_ref;
16599         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
16600         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
16601         LDKPublicKey revocation_key_ref;
16602         CHECK(*((uint32_t*)revocation_key) == 33);
16603         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
16604         LDKTransaction ret_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
16605         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16606         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16607         Transaction_free(ret_var);
16608         return ret_arr;
16609 }
16610
16611 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
16612         LDKChannelTransactionParameters this_obj_conv;
16613         this_obj_conv.inner = (void*)(this_obj & (~1));
16614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16615         ChannelTransactionParameters_free(this_obj_conv);
16616 }
16617
16618 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
16619         LDKChannelTransactionParameters this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
16623         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16624         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16625         long ret_ref = (long)ret_var.inner;
16626         if (ret_var.is_owned) {
16627                 ret_ref |= 1;
16628         }
16629         return ret_ref;
16630 }
16631
16632 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
16633         LDKChannelTransactionParameters this_ptr_conv;
16634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16635         this_ptr_conv.is_owned = false;
16636         LDKChannelPublicKeys val_conv;
16637         val_conv.inner = (void*)(val & (~1));
16638         val_conv.is_owned = (val & 1) || (val == 0);
16639         val_conv = ChannelPublicKeys_clone(&val_conv);
16640         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
16641 }
16642
16643 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
16644         LDKChannelTransactionParameters this_ptr_conv;
16645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16646         this_ptr_conv.is_owned = false;
16647         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
16648         return ret_val;
16649 }
16650
16651 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
16652         LDKChannelTransactionParameters this_ptr_conv;
16653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16654         this_ptr_conv.is_owned = false;
16655         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
16656 }
16657
16658 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
16659         LDKChannelTransactionParameters this_ptr_conv;
16660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16661         this_ptr_conv.is_owned = false;
16662         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
16663         return ret_val;
16664 }
16665
16666 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
16667         LDKChannelTransactionParameters this_ptr_conv;
16668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16669         this_ptr_conv.is_owned = false;
16670         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
16671 }
16672
16673 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
16674         LDKChannelTransactionParameters this_ptr_conv;
16675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16676         this_ptr_conv.is_owned = false;
16677         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
16678         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16679         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16680         long ret_ref = (long)ret_var.inner;
16681         if (ret_var.is_owned) {
16682                 ret_ref |= 1;
16683         }
16684         return ret_ref;
16685 }
16686
16687 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
16688         LDKChannelTransactionParameters this_ptr_conv;
16689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16690         this_ptr_conv.is_owned = false;
16691         LDKCounterpartyChannelTransactionParameters val_conv;
16692         val_conv.inner = (void*)(val & (~1));
16693         val_conv.is_owned = (val & 1) || (val == 0);
16694         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
16695         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
16696 }
16697
16698 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
16699         LDKChannelTransactionParameters this_ptr_conv;
16700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16701         this_ptr_conv.is_owned = false;
16702         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_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_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
16713         LDKChannelTransactionParameters this_ptr_conv;
16714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16715         this_ptr_conv.is_owned = false;
16716         LDKOutPoint val_conv;
16717         val_conv.inner = (void*)(val & (~1));
16718         val_conv.is_owned = (val & 1) || (val == 0);
16719         val_conv = OutPoint_clone(&val_conv);
16720         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
16721 }
16722
16723 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) {
16724         LDKChannelPublicKeys holder_pubkeys_arg_conv;
16725         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
16726         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
16727         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
16728         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
16729         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
16730         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
16731         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
16732         LDKOutPoint funding_outpoint_arg_conv;
16733         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
16734         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
16735         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
16736         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);
16737         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16738         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16739         long ret_ref = (long)ret_var.inner;
16740         if (ret_var.is_owned) {
16741                 ret_ref |= 1;
16742         }
16743         return ret_ref;
16744 }
16745
16746 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
16747         LDKChannelTransactionParameters orig_conv;
16748         orig_conv.inner = (void*)(orig & (~1));
16749         orig_conv.is_owned = false;
16750         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
16751         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16752         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16753         long ret_ref = (long)ret_var.inner;
16754         if (ret_var.is_owned) {
16755                 ret_ref |= 1;
16756         }
16757         return ret_ref;
16758 }
16759
16760 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
16761         LDKCounterpartyChannelTransactionParameters this_obj_conv;
16762         this_obj_conv.inner = (void*)(this_obj & (~1));
16763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16764         CounterpartyChannelTransactionParameters_free(this_obj_conv);
16765 }
16766
16767 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
16768         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16770         this_ptr_conv.is_owned = false;
16771         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
16772         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16773         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16774         long ret_ref = (long)ret_var.inner;
16775         if (ret_var.is_owned) {
16776                 ret_ref |= 1;
16777         }
16778         return ret_ref;
16779 }
16780
16781 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
16782         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16784         this_ptr_conv.is_owned = false;
16785         LDKChannelPublicKeys val_conv;
16786         val_conv.inner = (void*)(val & (~1));
16787         val_conv.is_owned = (val & 1) || (val == 0);
16788         val_conv = ChannelPublicKeys_clone(&val_conv);
16789         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
16790 }
16791
16792 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
16793         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16795         this_ptr_conv.is_owned = false;
16796         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
16797         return ret_val;
16798 }
16799
16800 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
16801         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
16802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16803         this_ptr_conv.is_owned = false;
16804         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
16805 }
16806
16807 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
16808         LDKChannelPublicKeys pubkeys_arg_conv;
16809         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
16810         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
16811         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
16812         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
16813         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16814         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16815         long ret_ref = (long)ret_var.inner;
16816         if (ret_var.is_owned) {
16817                 ret_ref |= 1;
16818         }
16819         return ret_ref;
16820 }
16821
16822 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
16823         LDKCounterpartyChannelTransactionParameters orig_conv;
16824         orig_conv.inner = (void*)(orig & (~1));
16825         orig_conv.is_owned = false;
16826         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
16827         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16828         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16829         long ret_ref = (long)ret_var.inner;
16830         if (ret_var.is_owned) {
16831                 ret_ref |= 1;
16832         }
16833         return ret_ref;
16834 }
16835
16836 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
16837         LDKChannelTransactionParameters this_arg_conv;
16838         this_arg_conv.inner = (void*)(this_arg & (~1));
16839         this_arg_conv.is_owned = false;
16840         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
16841         return ret_val;
16842 }
16843
16844 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
16845         LDKChannelTransactionParameters this_arg_conv;
16846         this_arg_conv.inner = (void*)(this_arg & (~1));
16847         this_arg_conv.is_owned = false;
16848         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
16849         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16850         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16851         long ret_ref = (long)ret_var.inner;
16852         if (ret_var.is_owned) {
16853                 ret_ref |= 1;
16854         }
16855         return ret_ref;
16856 }
16857
16858 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
16859         LDKChannelTransactionParameters this_arg_conv;
16860         this_arg_conv.inner = (void*)(this_arg & (~1));
16861         this_arg_conv.is_owned = false;
16862         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
16863         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16864         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16865         long ret_ref = (long)ret_var.inner;
16866         if (ret_var.is_owned) {
16867                 ret_ref |= 1;
16868         }
16869         return ret_ref;
16870 }
16871
16872 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
16873         LDKCounterpartyChannelTransactionParameters obj_conv;
16874         obj_conv.inner = (void*)(obj & (~1));
16875         obj_conv.is_owned = false;
16876         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
16877         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16878         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16879         CVec_u8Z_free(ret_var);
16880         return ret_arr;
16881 }
16882
16883 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
16884         LDKu8slice ser_ref;
16885         ser_ref.datalen = *((uint32_t*)ser);
16886         ser_ref.data = (int8_t*)(ser + 4);
16887         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16888         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
16889         return (long)ret_conv;
16890 }
16891
16892 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
16893         LDKChannelTransactionParameters obj_conv;
16894         obj_conv.inner = (void*)(obj & (~1));
16895         obj_conv.is_owned = false;
16896         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
16897         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16898         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16899         CVec_u8Z_free(ret_var);
16900         return ret_arr;
16901 }
16902
16903 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
16904         LDKu8slice ser_ref;
16905         ser_ref.datalen = *((uint32_t*)ser);
16906         ser_ref.data = (int8_t*)(ser + 4);
16907         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16908         *ret_conv = ChannelTransactionParameters_read(ser_ref);
16909         return (long)ret_conv;
16910 }
16911
16912 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
16913         LDKDirectedChannelTransactionParameters this_obj_conv;
16914         this_obj_conv.inner = (void*)(this_obj & (~1));
16915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16916         DirectedChannelTransactionParameters_free(this_obj_conv);
16917 }
16918
16919 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
16920         LDKDirectedChannelTransactionParameters this_arg_conv;
16921         this_arg_conv.inner = (void*)(this_arg & (~1));
16922         this_arg_conv.is_owned = false;
16923         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
16924         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16925         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16926         long ret_ref = (long)ret_var.inner;
16927         if (ret_var.is_owned) {
16928                 ret_ref |= 1;
16929         }
16930         return ret_ref;
16931 }
16932
16933 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
16934         LDKDirectedChannelTransactionParameters this_arg_conv;
16935         this_arg_conv.inner = (void*)(this_arg & (~1));
16936         this_arg_conv.is_owned = false;
16937         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
16938         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16939         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16940         long ret_ref = (long)ret_var.inner;
16941         if (ret_var.is_owned) {
16942                 ret_ref |= 1;
16943         }
16944         return ret_ref;
16945 }
16946
16947 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
16948         LDKDirectedChannelTransactionParameters this_arg_conv;
16949         this_arg_conv.inner = (void*)(this_arg & (~1));
16950         this_arg_conv.is_owned = false;
16951         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
16952         return ret_val;
16953 }
16954
16955 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
16956         LDKDirectedChannelTransactionParameters this_arg_conv;
16957         this_arg_conv.inner = (void*)(this_arg & (~1));
16958         this_arg_conv.is_owned = false;
16959         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
16960         return ret_val;
16961 }
16962
16963 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
16964         LDKDirectedChannelTransactionParameters this_arg_conv;
16965         this_arg_conv.inner = (void*)(this_arg & (~1));
16966         this_arg_conv.is_owned = false;
16967         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
16968         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16969         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16970         long ret_ref = (long)ret_var.inner;
16971         if (ret_var.is_owned) {
16972                 ret_ref |= 1;
16973         }
16974         return ret_ref;
16975 }
16976
16977 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
16978         LDKHolderCommitmentTransaction this_obj_conv;
16979         this_obj_conv.inner = (void*)(this_obj & (~1));
16980         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16981         HolderCommitmentTransaction_free(this_obj_conv);
16982 }
16983
16984 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
16985         LDKHolderCommitmentTransaction this_ptr_conv;
16986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16987         this_ptr_conv.is_owned = false;
16988         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
16989         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
16990         return ret_arr;
16991 }
16992
16993 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
16994         LDKHolderCommitmentTransaction this_ptr_conv;
16995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16996         this_ptr_conv.is_owned = false;
16997         LDKSignature val_ref;
16998         CHECK(*((uint32_t*)val) == 64);
16999         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17000         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
17001 }
17002
17003 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
17004         LDKHolderCommitmentTransaction this_ptr_conv;
17005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17006         this_ptr_conv.is_owned = false;
17007         LDKCVec_SignatureZ val_constr;
17008         val_constr.datalen = *((uint32_t*)val);
17009         if (val_constr.datalen > 0)
17010                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17011         else
17012                 val_constr.data = NULL;
17013         int8_tArray* val_vals = (int8_tArray*)(val + 4);
17014         for (size_t m = 0; m < val_constr.datalen; m++) {
17015                 int8_tArray val_conv_12 = val_vals[m];
17016                 LDKSignature val_conv_12_ref;
17017                 CHECK(*((uint32_t*)val_conv_12) == 64);
17018                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
17019                 val_constr.data[m] = val_conv_12_ref;
17020         }
17021         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
17022 }
17023
17024 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
17025         LDKHolderCommitmentTransaction orig_conv;
17026         orig_conv.inner = (void*)(orig & (~1));
17027         orig_conv.is_owned = false;
17028         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
17029         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17030         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17031         long ret_ref = (long)ret_var.inner;
17032         if (ret_var.is_owned) {
17033                 ret_ref |= 1;
17034         }
17035         return ret_ref;
17036 }
17037
17038 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
17039         LDKHolderCommitmentTransaction obj_conv;
17040         obj_conv.inner = (void*)(obj & (~1));
17041         obj_conv.is_owned = false;
17042         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
17043         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17044         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17045         CVec_u8Z_free(ret_var);
17046         return ret_arr;
17047 }
17048
17049 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
17050         LDKu8slice ser_ref;
17051         ser_ref.datalen = *((uint32_t*)ser);
17052         ser_ref.data = (int8_t*)(ser + 4);
17053         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
17054         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
17055         return (long)ret_conv;
17056 }
17057
17058 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) {
17059         LDKCommitmentTransaction commitment_tx_conv;
17060         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
17061         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
17062         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
17063         LDKSignature counterparty_sig_ref;
17064         CHECK(*((uint32_t*)counterparty_sig) == 64);
17065         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
17066         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
17067         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
17068         if (counterparty_htlc_sigs_constr.datalen > 0)
17069                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17070         else
17071                 counterparty_htlc_sigs_constr.data = NULL;
17072         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
17073         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
17074                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
17075                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
17076                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
17077                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
17078                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
17079         }
17080         LDKPublicKey holder_funding_key_ref;
17081         CHECK(*((uint32_t*)holder_funding_key) == 33);
17082         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
17083         LDKPublicKey counterparty_funding_key_ref;
17084         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
17085         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
17086         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
17087         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17088         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17089         long ret_ref = (long)ret_var.inner;
17090         if (ret_var.is_owned) {
17091                 ret_ref |= 1;
17092         }
17093         return ret_ref;
17094 }
17095
17096 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
17097         LDKBuiltCommitmentTransaction this_obj_conv;
17098         this_obj_conv.inner = (void*)(this_obj & (~1));
17099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17100         BuiltCommitmentTransaction_free(this_obj_conv);
17101 }
17102
17103 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
17104         LDKBuiltCommitmentTransaction this_ptr_conv;
17105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17106         this_ptr_conv.is_owned = false;
17107         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
17108         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17109         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17110         Transaction_free(ret_var);
17111         return ret_arr;
17112 }
17113
17114 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
17115         LDKBuiltCommitmentTransaction this_ptr_conv;
17116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17117         this_ptr_conv.is_owned = false;
17118         LDKTransaction val_ref;
17119         val_ref.datalen = *((uint32_t*)val);
17120         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
17121         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17122         val_ref.data_is_owned = true;
17123         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
17124 }
17125
17126 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
17127         LDKBuiltCommitmentTransaction this_ptr_conv;
17128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17129         this_ptr_conv.is_owned = false;
17130         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17131         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
17132         return ret_arr;
17133 }
17134
17135 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
17136         LDKBuiltCommitmentTransaction this_ptr_conv;
17137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17138         this_ptr_conv.is_owned = false;
17139         LDKThirtyTwoBytes val_ref;
17140         CHECK(*((uint32_t*)val) == 32);
17141         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17142         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
17143 }
17144
17145 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
17146         LDKTransaction transaction_arg_ref;
17147         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
17148         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
17149         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
17150         transaction_arg_ref.data_is_owned = true;
17151         LDKThirtyTwoBytes txid_arg_ref;
17152         CHECK(*((uint32_t*)txid_arg) == 32);
17153         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
17154         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
17155         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17156         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17157         long ret_ref = (long)ret_var.inner;
17158         if (ret_var.is_owned) {
17159                 ret_ref |= 1;
17160         }
17161         return ret_ref;
17162 }
17163
17164 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
17165         LDKBuiltCommitmentTransaction orig_conv;
17166         orig_conv.inner = (void*)(orig & (~1));
17167         orig_conv.is_owned = false;
17168         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
17169         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17170         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17171         long ret_ref = (long)ret_var.inner;
17172         if (ret_var.is_owned) {
17173                 ret_ref |= 1;
17174         }
17175         return ret_ref;
17176 }
17177
17178 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
17179         LDKBuiltCommitmentTransaction obj_conv;
17180         obj_conv.inner = (void*)(obj & (~1));
17181         obj_conv.is_owned = false;
17182         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
17183         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17184         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17185         CVec_u8Z_free(ret_var);
17186         return ret_arr;
17187 }
17188
17189 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
17190         LDKu8slice ser_ref;
17191         ser_ref.datalen = *((uint32_t*)ser);
17192         ser_ref.data = (int8_t*)(ser + 4);
17193         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
17194         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
17195         return (long)ret_conv;
17196 }
17197
17198 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
17199         LDKBuiltCommitmentTransaction this_arg_conv;
17200         this_arg_conv.inner = (void*)(this_arg & (~1));
17201         this_arg_conv.is_owned = false;
17202         LDKu8slice funding_redeemscript_ref;
17203         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17204         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17205         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17206         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
17207         return ret_arr;
17208 }
17209
17210 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) {
17211         LDKBuiltCommitmentTransaction this_arg_conv;
17212         this_arg_conv.inner = (void*)(this_arg & (~1));
17213         this_arg_conv.is_owned = false;
17214         unsigned char funding_key_arr[32];
17215         CHECK(*((uint32_t*)funding_key) == 32);
17216         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
17217         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
17218         LDKu8slice funding_redeemscript_ref;
17219         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
17220         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
17221         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17222         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
17223         return ret_arr;
17224 }
17225
17226 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
17227         LDKCommitmentTransaction this_obj_conv;
17228         this_obj_conv.inner = (void*)(this_obj & (~1));
17229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17230         CommitmentTransaction_free(this_obj_conv);
17231 }
17232
17233 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
17234         LDKCommitmentTransaction orig_conv;
17235         orig_conv.inner = (void*)(orig & (~1));
17236         orig_conv.is_owned = false;
17237         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
17238         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17239         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17240         long ret_ref = (long)ret_var.inner;
17241         if (ret_var.is_owned) {
17242                 ret_ref |= 1;
17243         }
17244         return ret_ref;
17245 }
17246
17247 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
17248         LDKCommitmentTransaction obj_conv;
17249         obj_conv.inner = (void*)(obj & (~1));
17250         obj_conv.is_owned = false;
17251         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
17252         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17253         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17254         CVec_u8Z_free(ret_var);
17255         return ret_arr;
17256 }
17257
17258 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
17259         LDKu8slice ser_ref;
17260         ser_ref.datalen = *((uint32_t*)ser);
17261         ser_ref.data = (int8_t*)(ser + 4);
17262         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
17263         *ret_conv = CommitmentTransaction_read(ser_ref);
17264         return (long)ret_conv;
17265 }
17266
17267 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
17268         LDKCommitmentTransaction this_arg_conv;
17269         this_arg_conv.inner = (void*)(this_arg & (~1));
17270         this_arg_conv.is_owned = false;
17271         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
17272         return ret_val;
17273 }
17274
17275 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
17276         LDKCommitmentTransaction this_arg_conv;
17277         this_arg_conv.inner = (void*)(this_arg & (~1));
17278         this_arg_conv.is_owned = false;
17279         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
17280         return ret_val;
17281 }
17282
17283 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
17284         LDKCommitmentTransaction this_arg_conv;
17285         this_arg_conv.inner = (void*)(this_arg & (~1));
17286         this_arg_conv.is_owned = false;
17287         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
17288         return ret_val;
17289 }
17290
17291 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
17292         LDKCommitmentTransaction this_arg_conv;
17293         this_arg_conv.inner = (void*)(this_arg & (~1));
17294         this_arg_conv.is_owned = false;
17295         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
17296         return ret_val;
17297 }
17298
17299 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
17300         LDKCommitmentTransaction this_arg_conv;
17301         this_arg_conv.inner = (void*)(this_arg & (~1));
17302         this_arg_conv.is_owned = false;
17303         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&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_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
17314         LDKCommitmentTransaction this_arg_conv;
17315         this_arg_conv.inner = (void*)(this_arg & (~1));
17316         this_arg_conv.is_owned = false;
17317         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17318         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17319         channel_parameters_conv.is_owned = false;
17320         LDKChannelPublicKeys broadcaster_keys_conv;
17321         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
17322         broadcaster_keys_conv.is_owned = false;
17323         LDKChannelPublicKeys countersignatory_keys_conv;
17324         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
17325         countersignatory_keys_conv.is_owned = false;
17326         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
17327         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
17328         return (long)ret_conv;
17329 }
17330
17331 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
17332         LDKTrustedCommitmentTransaction this_obj_conv;
17333         this_obj_conv.inner = (void*)(this_obj & (~1));
17334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17335         TrustedCommitmentTransaction_free(this_obj_conv);
17336 }
17337
17338 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
17339         LDKTrustedCommitmentTransaction this_arg_conv;
17340         this_arg_conv.inner = (void*)(this_arg & (~1));
17341         this_arg_conv.is_owned = false;
17342         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17343         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
17344         return ret_arr;
17345 }
17346
17347 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
17348         LDKTrustedCommitmentTransaction this_arg_conv;
17349         this_arg_conv.inner = (void*)(this_arg & (~1));
17350         this_arg_conv.is_owned = false;
17351         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
17352         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17353         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17354         long ret_ref = (long)ret_var.inner;
17355         if (ret_var.is_owned) {
17356                 ret_ref |= 1;
17357         }
17358         return ret_ref;
17359 }
17360
17361 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
17362         LDKTrustedCommitmentTransaction this_arg_conv;
17363         this_arg_conv.inner = (void*)(this_arg & (~1));
17364         this_arg_conv.is_owned = false;
17365         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
17366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17368         long ret_ref = (long)ret_var.inner;
17369         if (ret_var.is_owned) {
17370                 ret_ref |= 1;
17371         }
17372         return ret_ref;
17373 }
17374
17375 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
17376         LDKTrustedCommitmentTransaction this_arg_conv;
17377         this_arg_conv.inner = (void*)(this_arg & (~1));
17378         this_arg_conv.is_owned = false;
17379         unsigned char htlc_base_key_arr[32];
17380         CHECK(*((uint32_t*)htlc_base_key) == 32);
17381         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
17382         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
17383         LDKDirectedChannelTransactionParameters channel_parameters_conv;
17384         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
17385         channel_parameters_conv.is_owned = false;
17386         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
17387         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
17388         return (long)ret_conv;
17389 }
17390
17391 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) {
17392         LDKPublicKey broadcaster_payment_basepoint_ref;
17393         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
17394         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
17395         LDKPublicKey countersignatory_payment_basepoint_ref;
17396         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
17397         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
17398         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
17399         return ret_val;
17400 }
17401
17402 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
17403         LDKInitFeatures orig_conv;
17404         orig_conv.inner = (void*)(orig & (~1));
17405         orig_conv.is_owned = false;
17406         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
17407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17409         long ret_ref = (long)ret_var.inner;
17410         if (ret_var.is_owned) {
17411                 ret_ref |= 1;
17412         }
17413         return ret_ref;
17414 }
17415
17416 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
17417         LDKNodeFeatures orig_conv;
17418         orig_conv.inner = (void*)(orig & (~1));
17419         orig_conv.is_owned = false;
17420         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
17421         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17422         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17423         long ret_ref = (long)ret_var.inner;
17424         if (ret_var.is_owned) {
17425                 ret_ref |= 1;
17426         }
17427         return ret_ref;
17428 }
17429
17430 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
17431         LDKChannelFeatures orig_conv;
17432         orig_conv.inner = (void*)(orig & (~1));
17433         orig_conv.is_owned = false;
17434         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
17435         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17436         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17437         long ret_ref = (long)ret_var.inner;
17438         if (ret_var.is_owned) {
17439                 ret_ref |= 1;
17440         }
17441         return ret_ref;
17442 }
17443
17444 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
17445         LDKInvoiceFeatures orig_conv;
17446         orig_conv.inner = (void*)(orig & (~1));
17447         orig_conv.is_owned = false;
17448         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
17449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17451         long ret_ref = (long)ret_var.inner;
17452         if (ret_var.is_owned) {
17453                 ret_ref |= 1;
17454         }
17455         return ret_ref;
17456 }
17457
17458 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
17459         LDKInitFeatures this_obj_conv;
17460         this_obj_conv.inner = (void*)(this_obj & (~1));
17461         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17462         InitFeatures_free(this_obj_conv);
17463 }
17464
17465 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
17466         LDKNodeFeatures this_obj_conv;
17467         this_obj_conv.inner = (void*)(this_obj & (~1));
17468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17469         NodeFeatures_free(this_obj_conv);
17470 }
17471
17472 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
17473         LDKChannelFeatures this_obj_conv;
17474         this_obj_conv.inner = (void*)(this_obj & (~1));
17475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17476         ChannelFeatures_free(this_obj_conv);
17477 }
17478
17479 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
17480         LDKInvoiceFeatures this_obj_conv;
17481         this_obj_conv.inner = (void*)(this_obj & (~1));
17482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17483         InvoiceFeatures_free(this_obj_conv);
17484 }
17485
17486 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
17487         LDKInitFeatures ret_var = InitFeatures_empty();
17488         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17489         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17490         long ret_ref = (long)ret_var.inner;
17491         if (ret_var.is_owned) {
17492                 ret_ref |= 1;
17493         }
17494         return ret_ref;
17495 }
17496
17497 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
17498         LDKInitFeatures ret_var = InitFeatures_known();
17499         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17500         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17501         long ret_ref = (long)ret_var.inner;
17502         if (ret_var.is_owned) {
17503                 ret_ref |= 1;
17504         }
17505         return ret_ref;
17506 }
17507
17508 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
17509         LDKNodeFeatures ret_var = NodeFeatures_empty();
17510         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17511         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17512         long ret_ref = (long)ret_var.inner;
17513         if (ret_var.is_owned) {
17514                 ret_ref |= 1;
17515         }
17516         return ret_ref;
17517 }
17518
17519 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
17520         LDKNodeFeatures ret_var = NodeFeatures_known();
17521         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17522         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17523         long ret_ref = (long)ret_var.inner;
17524         if (ret_var.is_owned) {
17525                 ret_ref |= 1;
17526         }
17527         return ret_ref;
17528 }
17529
17530 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
17531         LDKChannelFeatures ret_var = ChannelFeatures_empty();
17532         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17533         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17534         long ret_ref = (long)ret_var.inner;
17535         if (ret_var.is_owned) {
17536                 ret_ref |= 1;
17537         }
17538         return ret_ref;
17539 }
17540
17541 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
17542         LDKChannelFeatures ret_var = ChannelFeatures_known();
17543         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17544         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17545         long ret_ref = (long)ret_var.inner;
17546         if (ret_var.is_owned) {
17547                 ret_ref |= 1;
17548         }
17549         return ret_ref;
17550 }
17551
17552 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
17553         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
17554         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17555         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17556         long ret_ref = (long)ret_var.inner;
17557         if (ret_var.is_owned) {
17558                 ret_ref |= 1;
17559         }
17560         return ret_ref;
17561 }
17562
17563 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
17564         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
17565         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17566         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17567         long ret_ref = (long)ret_var.inner;
17568         if (ret_var.is_owned) {
17569                 ret_ref |= 1;
17570         }
17571         return ret_ref;
17572 }
17573
17574 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
17575         LDKInitFeatures obj_conv;
17576         obj_conv.inner = (void*)(obj & (~1));
17577         obj_conv.is_owned = false;
17578         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
17579         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17580         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17581         CVec_u8Z_free(ret_var);
17582         return ret_arr;
17583 }
17584
17585 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
17586         LDKNodeFeatures obj_conv;
17587         obj_conv.inner = (void*)(obj & (~1));
17588         obj_conv.is_owned = false;
17589         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
17590         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17591         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17592         CVec_u8Z_free(ret_var);
17593         return ret_arr;
17594 }
17595
17596 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
17597         LDKChannelFeatures obj_conv;
17598         obj_conv.inner = (void*)(obj & (~1));
17599         obj_conv.is_owned = false;
17600         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
17601         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17602         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17603         CVec_u8Z_free(ret_var);
17604         return ret_arr;
17605 }
17606
17607 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
17608         LDKInvoiceFeatures obj_conv;
17609         obj_conv.inner = (void*)(obj & (~1));
17610         obj_conv.is_owned = false;
17611         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
17612         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17613         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17614         CVec_u8Z_free(ret_var);
17615         return ret_arr;
17616 }
17617
17618 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
17619         LDKu8slice ser_ref;
17620         ser_ref.datalen = *((uint32_t*)ser);
17621         ser_ref.data = (int8_t*)(ser + 4);
17622         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17623         *ret_conv = InitFeatures_read(ser_ref);
17624         return (long)ret_conv;
17625 }
17626
17627 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
17628         LDKu8slice ser_ref;
17629         ser_ref.datalen = *((uint32_t*)ser);
17630         ser_ref.data = (int8_t*)(ser + 4);
17631         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17632         *ret_conv = NodeFeatures_read(ser_ref);
17633         return (long)ret_conv;
17634 }
17635
17636 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
17637         LDKu8slice ser_ref;
17638         ser_ref.datalen = *((uint32_t*)ser);
17639         ser_ref.data = (int8_t*)(ser + 4);
17640         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17641         *ret_conv = ChannelFeatures_read(ser_ref);
17642         return (long)ret_conv;
17643 }
17644
17645 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
17646         LDKu8slice ser_ref;
17647         ser_ref.datalen = *((uint32_t*)ser);
17648         ser_ref.data = (int8_t*)(ser + 4);
17649         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17650         *ret_conv = InvoiceFeatures_read(ser_ref);
17651         return (long)ret_conv;
17652 }
17653
17654 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
17655         LDKRouteHop this_obj_conv;
17656         this_obj_conv.inner = (void*)(this_obj & (~1));
17657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17658         RouteHop_free(this_obj_conv);
17659 }
17660
17661 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
17662         LDKRouteHop this_ptr_conv;
17663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17664         this_ptr_conv.is_owned = false;
17665         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17666         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
17667         return ret_arr;
17668 }
17669
17670 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
17671         LDKRouteHop this_ptr_conv;
17672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17673         this_ptr_conv.is_owned = false;
17674         LDKPublicKey val_ref;
17675         CHECK(*((uint32_t*)val) == 33);
17676         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17677         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
17678 }
17679
17680 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
17681         LDKRouteHop this_ptr_conv;
17682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17683         this_ptr_conv.is_owned = false;
17684         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
17685         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17686         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17687         long ret_ref = (long)ret_var.inner;
17688         if (ret_var.is_owned) {
17689                 ret_ref |= 1;
17690         }
17691         return ret_ref;
17692 }
17693
17694 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
17695         LDKRouteHop this_ptr_conv;
17696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17697         this_ptr_conv.is_owned = false;
17698         LDKNodeFeatures val_conv;
17699         val_conv.inner = (void*)(val & (~1));
17700         val_conv.is_owned = (val & 1) || (val == 0);
17701         val_conv = NodeFeatures_clone(&val_conv);
17702         RouteHop_set_node_features(&this_ptr_conv, val_conv);
17703 }
17704
17705 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
17706         LDKRouteHop this_ptr_conv;
17707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17708         this_ptr_conv.is_owned = false;
17709         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
17710         return ret_val;
17711 }
17712
17713 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17714         LDKRouteHop this_ptr_conv;
17715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17716         this_ptr_conv.is_owned = false;
17717         RouteHop_set_short_channel_id(&this_ptr_conv, val);
17718 }
17719
17720 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
17721         LDKRouteHop this_ptr_conv;
17722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17723         this_ptr_conv.is_owned = false;
17724         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
17725         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17726         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17727         long ret_ref = (long)ret_var.inner;
17728         if (ret_var.is_owned) {
17729                 ret_ref |= 1;
17730         }
17731         return ret_ref;
17732 }
17733
17734 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
17735         LDKRouteHop this_ptr_conv;
17736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17737         this_ptr_conv.is_owned = false;
17738         LDKChannelFeatures val_conv;
17739         val_conv.inner = (void*)(val & (~1));
17740         val_conv.is_owned = (val & 1) || (val == 0);
17741         val_conv = ChannelFeatures_clone(&val_conv);
17742         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
17743 }
17744
17745 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
17746         LDKRouteHop this_ptr_conv;
17747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17748         this_ptr_conv.is_owned = false;
17749         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
17750         return ret_val;
17751 }
17752
17753 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
17754         LDKRouteHop this_ptr_conv;
17755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17756         this_ptr_conv.is_owned = false;
17757         RouteHop_set_fee_msat(&this_ptr_conv, val);
17758 }
17759
17760 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
17761         LDKRouteHop this_ptr_conv;
17762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17763         this_ptr_conv.is_owned = false;
17764         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
17765         return ret_val;
17766 }
17767
17768 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
17769         LDKRouteHop this_ptr_conv;
17770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17771         this_ptr_conv.is_owned = false;
17772         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
17773 }
17774
17775 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) {
17776         LDKPublicKey pubkey_arg_ref;
17777         CHECK(*((uint32_t*)pubkey_arg) == 33);
17778         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
17779         LDKNodeFeatures node_features_arg_conv;
17780         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
17781         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
17782         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
17783         LDKChannelFeatures channel_features_arg_conv;
17784         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
17785         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
17786         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
17787         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);
17788         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17789         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17790         long ret_ref = (long)ret_var.inner;
17791         if (ret_var.is_owned) {
17792                 ret_ref |= 1;
17793         }
17794         return ret_ref;
17795 }
17796
17797 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
17798         LDKRouteHop orig_conv;
17799         orig_conv.inner = (void*)(orig & (~1));
17800         orig_conv.is_owned = false;
17801         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
17802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17804         long ret_ref = (long)ret_var.inner;
17805         if (ret_var.is_owned) {
17806                 ret_ref |= 1;
17807         }
17808         return ret_ref;
17809 }
17810
17811 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
17812         LDKRoute 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         Route_free(this_obj_conv);
17816 }
17817
17818 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
17819         LDKRoute this_ptr_conv;
17820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17821         this_ptr_conv.is_owned = false;
17822         LDKCVec_CVec_RouteHopZZ val_constr;
17823         val_constr.datalen = *((uint32_t*)val);
17824         if (val_constr.datalen > 0)
17825                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17826         else
17827                 val_constr.data = NULL;
17828         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
17829         for (size_t m = 0; m < val_constr.datalen; m++) {
17830                 uint32_tArray val_conv_12 = val_vals[m];
17831                 LDKCVec_RouteHopZ val_conv_12_constr;
17832                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
17833                 if (val_conv_12_constr.datalen > 0)
17834                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17835                 else
17836                         val_conv_12_constr.data = NULL;
17837                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
17838                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
17839                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
17840                         LDKRouteHop val_conv_12_conv_10_conv;
17841                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
17842                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
17843                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
17844                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
17845                 }
17846                 val_constr.data[m] = val_conv_12_constr;
17847         }
17848         Route_set_paths(&this_ptr_conv, val_constr);
17849 }
17850
17851 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
17852         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
17853         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
17854         if (paths_arg_constr.datalen > 0)
17855                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17856         else
17857                 paths_arg_constr.data = NULL;
17858         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
17859         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
17860                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
17861                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
17862                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
17863                 if (paths_arg_conv_12_constr.datalen > 0)
17864                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17865                 else
17866                         paths_arg_conv_12_constr.data = NULL;
17867                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
17868                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
17869                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
17870                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
17871                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
17872                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
17873                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
17874                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
17875                 }
17876                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
17877         }
17878         LDKRoute ret_var = Route_new(paths_arg_constr);
17879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17881         long ret_ref = (long)ret_var.inner;
17882         if (ret_var.is_owned) {
17883                 ret_ref |= 1;
17884         }
17885         return ret_ref;
17886 }
17887
17888 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
17889         LDKRoute orig_conv;
17890         orig_conv.inner = (void*)(orig & (~1));
17891         orig_conv.is_owned = false;
17892         LDKRoute ret_var = Route_clone(&orig_conv);
17893         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17894         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17895         long ret_ref = (long)ret_var.inner;
17896         if (ret_var.is_owned) {
17897                 ret_ref |= 1;
17898         }
17899         return ret_ref;
17900 }
17901
17902 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
17903         LDKRoute obj_conv;
17904         obj_conv.inner = (void*)(obj & (~1));
17905         obj_conv.is_owned = false;
17906         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
17907         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17908         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17909         CVec_u8Z_free(ret_var);
17910         return ret_arr;
17911 }
17912
17913 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
17914         LDKu8slice ser_ref;
17915         ser_ref.datalen = *((uint32_t*)ser);
17916         ser_ref.data = (int8_t*)(ser + 4);
17917         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17918         *ret_conv = Route_read(ser_ref);
17919         return (long)ret_conv;
17920 }
17921
17922 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
17923         LDKRouteHint this_obj_conv;
17924         this_obj_conv.inner = (void*)(this_obj & (~1));
17925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17926         RouteHint_free(this_obj_conv);
17927 }
17928
17929 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
17930         LDKRouteHint this_ptr_conv;
17931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17932         this_ptr_conv.is_owned = false;
17933         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17934         memcpy((uint8_t*)(ret_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
17935         return ret_arr;
17936 }
17937
17938 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
17939         LDKRouteHint this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         LDKPublicKey val_ref;
17943         CHECK(*((uint32_t*)val) == 33);
17944         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17945         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
17946 }
17947
17948 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
17949         LDKRouteHint this_ptr_conv;
17950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17951         this_ptr_conv.is_owned = false;
17952         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
17953         return ret_val;
17954 }
17955
17956 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
17957         LDKRouteHint this_ptr_conv;
17958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17959         this_ptr_conv.is_owned = false;
17960         RouteHint_set_short_channel_id(&this_ptr_conv, val);
17961 }
17962
17963 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
17964         LDKRouteHint this_ptr_conv;
17965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17966         this_ptr_conv.is_owned = false;
17967         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
17968         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17969         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17970         long ret_ref = (long)ret_var.inner;
17971         if (ret_var.is_owned) {
17972                 ret_ref |= 1;
17973         }
17974         return ret_ref;
17975 }
17976
17977 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
17978         LDKRouteHint this_ptr_conv;
17979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17980         this_ptr_conv.is_owned = false;
17981         LDKRoutingFees val_conv;
17982         val_conv.inner = (void*)(val & (~1));
17983         val_conv.is_owned = (val & 1) || (val == 0);
17984         val_conv = RoutingFees_clone(&val_conv);
17985         RouteHint_set_fees(&this_ptr_conv, val_conv);
17986 }
17987
17988 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
17989         LDKRouteHint this_ptr_conv;
17990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17991         this_ptr_conv.is_owned = false;
17992         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
17993         return ret_val;
17994 }
17995
17996 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17997         LDKRouteHint this_ptr_conv;
17998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17999         this_ptr_conv.is_owned = false;
18000         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
18001 }
18002
18003 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
18004         LDKRouteHint orig_conv;
18005         orig_conv.inner = (void*)(orig & (~1));
18006         orig_conv.is_owned = false;
18007         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
18008         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18009         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18010         long ret_ref = (long)ret_var.inner;
18011         if (ret_var.is_owned) {
18012                 ret_ref |= 1;
18013         }
18014         return ret_ref;
18015 }
18016
18017 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
18018         LDKPublicKey our_node_id_ref;
18019         CHECK(*((uint32_t*)our_node_id) == 33);
18020         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
18021         LDKNetworkGraph network_conv;
18022         network_conv.inner = (void*)(network & (~1));
18023         network_conv.is_owned = false;
18024         LDKPublicKey payee_ref;
18025         CHECK(*((uint32_t*)payee) == 33);
18026         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
18027         LDKInvoiceFeatures payee_features_conv;
18028         payee_features_conv.inner = (void*)(payee_features & (~1));
18029         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
18030         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
18031         LDKCVec_ChannelDetailsZ first_hops_constr;
18032         first_hops_constr.datalen = *((uint32_t*)first_hops);
18033         if (first_hops_constr.datalen > 0)
18034                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18035         else
18036                 first_hops_constr.data = NULL;
18037         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
18038         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
18039                 uint32_t first_hops_conv_16 = first_hops_vals[q];
18040                 LDKChannelDetails first_hops_conv_16_conv;
18041                 first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
18042                 first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
18043                 first_hops_constr.data[q] = first_hops_conv_16_conv;
18044         }
18045         LDKCVec_RouteHintZ last_hops_constr;
18046         last_hops_constr.datalen = *((uint32_t*)last_hops);
18047         if (last_hops_constr.datalen > 0)
18048                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18049         else
18050                 last_hops_constr.data = NULL;
18051         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
18052         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
18053                 uint32_t last_hops_conv_11 = last_hops_vals[l];
18054                 LDKRouteHint last_hops_conv_11_conv;
18055                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
18056                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
18057                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
18058                 last_hops_constr.data[l] = last_hops_conv_11_conv;
18059         }
18060         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18061         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
18062         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
18063         FREE(first_hops_constr.data);
18064         return (long)ret_conv;
18065 }
18066
18067 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
18068         LDKNetworkGraph this_obj_conv;
18069         this_obj_conv.inner = (void*)(this_obj & (~1));
18070         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18071         NetworkGraph_free(this_obj_conv);
18072 }
18073
18074 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
18075         LDKNetworkGraph orig_conv;
18076         orig_conv.inner = (void*)(orig & (~1));
18077         orig_conv.is_owned = false;
18078         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
18079         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18080         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18081         long ret_ref = (long)ret_var.inner;
18082         if (ret_var.is_owned) {
18083                 ret_ref |= 1;
18084         }
18085         return ret_ref;
18086 }
18087
18088 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_obj) {
18089         LDKLockedNetworkGraph this_obj_conv;
18090         this_obj_conv.inner = (void*)(this_obj & (~1));
18091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18092         LockedNetworkGraph_free(this_obj_conv);
18093 }
18094
18095 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
18096         LDKNetGraphMsgHandler this_obj_conv;
18097         this_obj_conv.inner = (void*)(this_obj & (~1));
18098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18099         NetGraphMsgHandler_free(this_obj_conv);
18100 }
18101
18102 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
18103         LDKThirtyTwoBytes genesis_hash_ref;
18104         CHECK(*((uint32_t*)genesis_hash) == 32);
18105         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
18106         LDKAccess *chain_access_conv_ptr = NULL;
18107         if (chain_access != 0) {
18108                 LDKAccess chain_access_conv;
18109                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18110                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18111                 *chain_access_conv_ptr = chain_access_conv;
18112         }
18113         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18114         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
18115         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18116         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18117         long ret_ref = (long)ret_var.inner;
18118         if (ret_var.is_owned) {
18119                 ret_ref |= 1;
18120         }
18121         return ret_ref;
18122 }
18123
18124 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
18125         LDKAccess *chain_access_conv_ptr = NULL;
18126         if (chain_access != 0) {
18127                 LDKAccess chain_access_conv;
18128                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18129                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18130                 *chain_access_conv_ptr = chain_access_conv;
18131         }
18132         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
18133         LDKNetworkGraph network_graph_conv;
18134         network_graph_conv.inner = (void*)(network_graph & (~1));
18135         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
18136         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
18137         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
18138         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18139         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18140         long ret_ref = (long)ret_var.inner;
18141         if (ret_var.is_owned) {
18142                 ret_ref |= 1;
18143         }
18144         return ret_ref;
18145 }
18146
18147 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
18148         LDKNetGraphMsgHandler this_arg_conv;
18149         this_arg_conv.inner = (void*)(this_arg & (~1));
18150         this_arg_conv.is_owned = false;
18151         LDKAccess *chain_access_conv_ptr = NULL;
18152         if (chain_access != 0) {
18153                 LDKAccess chain_access_conv;
18154                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
18155                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
18156                 *chain_access_conv_ptr = chain_access_conv;
18157         }
18158         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
18159 }
18160
18161 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
18162         LDKNetGraphMsgHandler this_arg_conv;
18163         this_arg_conv.inner = (void*)(this_arg & (~1));
18164         this_arg_conv.is_owned = false;
18165         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
18166         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18167         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18168         long ret_ref = (long)ret_var.inner;
18169         if (ret_var.is_owned) {
18170                 ret_ref |= 1;
18171         }
18172         return ret_ref;
18173 }
18174
18175 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
18176         LDKLockedNetworkGraph this_arg_conv;
18177         this_arg_conv.inner = (void*)(this_arg & (~1));
18178         this_arg_conv.is_owned = false;
18179         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
18180         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18181         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18182         long ret_ref = (long)ret_var.inner;
18183         if (ret_var.is_owned) {
18184                 ret_ref |= 1;
18185         }
18186         return ret_ref;
18187 }
18188
18189 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
18190         LDKNetGraphMsgHandler this_arg_conv;
18191         this_arg_conv.inner = (void*)(this_arg & (~1));
18192         this_arg_conv.is_owned = false;
18193         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
18194         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
18195         return (long)ret;
18196 }
18197
18198 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
18199         LDKNetGraphMsgHandler this_arg_conv;
18200         this_arg_conv.inner = (void*)(this_arg & (~1));
18201         this_arg_conv.is_owned = false;
18202         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
18203         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
18204         return (long)ret;
18205 }
18206
18207 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
18208         LDKDirectionalChannelInfo this_obj_conv;
18209         this_obj_conv.inner = (void*)(this_obj & (~1));
18210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18211         DirectionalChannelInfo_free(this_obj_conv);
18212 }
18213
18214 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
18215         LDKDirectionalChannelInfo this_ptr_conv;
18216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18217         this_ptr_conv.is_owned = false;
18218         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
18219         return ret_val;
18220 }
18221
18222 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
18223         LDKDirectionalChannelInfo this_ptr_conv;
18224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18225         this_ptr_conv.is_owned = false;
18226         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
18227 }
18228
18229 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
18230         LDKDirectionalChannelInfo this_ptr_conv;
18231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18232         this_ptr_conv.is_owned = false;
18233         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
18234         return ret_val;
18235 }
18236
18237 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
18238         LDKDirectionalChannelInfo this_ptr_conv;
18239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18240         this_ptr_conv.is_owned = false;
18241         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
18242 }
18243
18244 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
18245         LDKDirectionalChannelInfo this_ptr_conv;
18246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18247         this_ptr_conv.is_owned = false;
18248         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
18249         return ret_val;
18250 }
18251
18252 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
18253         LDKDirectionalChannelInfo this_ptr_conv;
18254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18255         this_ptr_conv.is_owned = false;
18256         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
18257 }
18258
18259 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
18260         LDKDirectionalChannelInfo this_ptr_conv;
18261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18262         this_ptr_conv.is_owned = false;
18263         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
18264         return ret_val;
18265 }
18266
18267 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
18268         LDKDirectionalChannelInfo this_ptr_conv;
18269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18270         this_ptr_conv.is_owned = false;
18271         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
18272 }
18273
18274 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
18275         LDKDirectionalChannelInfo this_ptr_conv;
18276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18277         this_ptr_conv.is_owned = false;
18278         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
18279         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18280         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18281         long ret_ref = (long)ret_var.inner;
18282         if (ret_var.is_owned) {
18283                 ret_ref |= 1;
18284         }
18285         return ret_ref;
18286 }
18287
18288 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
18289         LDKDirectionalChannelInfo this_ptr_conv;
18290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18291         this_ptr_conv.is_owned = false;
18292         LDKRoutingFees val_conv;
18293         val_conv.inner = (void*)(val & (~1));
18294         val_conv.is_owned = (val & 1) || (val == 0);
18295         val_conv = RoutingFees_clone(&val_conv);
18296         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
18297 }
18298
18299 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
18300         LDKDirectionalChannelInfo this_ptr_conv;
18301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18302         this_ptr_conv.is_owned = false;
18303         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
18304         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18305         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18306         long ret_ref = (long)ret_var.inner;
18307         if (ret_var.is_owned) {
18308                 ret_ref |= 1;
18309         }
18310         return ret_ref;
18311 }
18312
18313 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
18314         LDKDirectionalChannelInfo this_ptr_conv;
18315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18316         this_ptr_conv.is_owned = false;
18317         LDKChannelUpdate val_conv;
18318         val_conv.inner = (void*)(val & (~1));
18319         val_conv.is_owned = (val & 1) || (val == 0);
18320         val_conv = ChannelUpdate_clone(&val_conv);
18321         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
18322 }
18323
18324 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
18325         LDKDirectionalChannelInfo orig_conv;
18326         orig_conv.inner = (void*)(orig & (~1));
18327         orig_conv.is_owned = false;
18328         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
18329         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18330         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18331         long ret_ref = (long)ret_var.inner;
18332         if (ret_var.is_owned) {
18333                 ret_ref |= 1;
18334         }
18335         return ret_ref;
18336 }
18337
18338 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
18339         LDKDirectionalChannelInfo obj_conv;
18340         obj_conv.inner = (void*)(obj & (~1));
18341         obj_conv.is_owned = false;
18342         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
18343         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18344         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18345         CVec_u8Z_free(ret_var);
18346         return ret_arr;
18347 }
18348
18349 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
18350         LDKu8slice ser_ref;
18351         ser_ref.datalen = *((uint32_t*)ser);
18352         ser_ref.data = (int8_t*)(ser + 4);
18353         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
18354         *ret_conv = DirectionalChannelInfo_read(ser_ref);
18355         return (long)ret_conv;
18356 }
18357
18358 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
18359         LDKChannelInfo this_obj_conv;
18360         this_obj_conv.inner = (void*)(this_obj & (~1));
18361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18362         ChannelInfo_free(this_obj_conv);
18363 }
18364
18365 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
18366         LDKChannelInfo this_ptr_conv;
18367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18368         this_ptr_conv.is_owned = false;
18369         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
18370         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18371         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18372         long ret_ref = (long)ret_var.inner;
18373         if (ret_var.is_owned) {
18374                 ret_ref |= 1;
18375         }
18376         return ret_ref;
18377 }
18378
18379 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
18380         LDKChannelInfo this_ptr_conv;
18381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18382         this_ptr_conv.is_owned = false;
18383         LDKChannelFeatures val_conv;
18384         val_conv.inner = (void*)(val & (~1));
18385         val_conv.is_owned = (val & 1) || (val == 0);
18386         val_conv = ChannelFeatures_clone(&val_conv);
18387         ChannelInfo_set_features(&this_ptr_conv, val_conv);
18388 }
18389
18390 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
18391         LDKChannelInfo this_ptr_conv;
18392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18393         this_ptr_conv.is_owned = false;
18394         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18395         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
18396         return ret_arr;
18397 }
18398
18399 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
18400         LDKChannelInfo this_ptr_conv;
18401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18402         this_ptr_conv.is_owned = false;
18403         LDKPublicKey val_ref;
18404         CHECK(*((uint32_t*)val) == 33);
18405         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18406         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
18407 }
18408
18409 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
18410         LDKChannelInfo this_ptr_conv;
18411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18412         this_ptr_conv.is_owned = false;
18413         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
18414         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18415         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18416         long ret_ref = (long)ret_var.inner;
18417         if (ret_var.is_owned) {
18418                 ret_ref |= 1;
18419         }
18420         return ret_ref;
18421 }
18422
18423 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
18424         LDKChannelInfo this_ptr_conv;
18425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18426         this_ptr_conv.is_owned = false;
18427         LDKDirectionalChannelInfo val_conv;
18428         val_conv.inner = (void*)(val & (~1));
18429         val_conv.is_owned = (val & 1) || (val == 0);
18430         val_conv = DirectionalChannelInfo_clone(&val_conv);
18431         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
18432 }
18433
18434 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
18435         LDKChannelInfo this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18439         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
18440         return ret_arr;
18441 }
18442
18443 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
18444         LDKChannelInfo this_ptr_conv;
18445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18446         this_ptr_conv.is_owned = false;
18447         LDKPublicKey val_ref;
18448         CHECK(*((uint32_t*)val) == 33);
18449         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18450         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
18451 }
18452
18453 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
18454         LDKChannelInfo this_ptr_conv;
18455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18456         this_ptr_conv.is_owned = false;
18457         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
18458         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18459         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18460         long ret_ref = (long)ret_var.inner;
18461         if (ret_var.is_owned) {
18462                 ret_ref |= 1;
18463         }
18464         return ret_ref;
18465 }
18466
18467 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
18468         LDKChannelInfo this_ptr_conv;
18469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18470         this_ptr_conv.is_owned = false;
18471         LDKDirectionalChannelInfo val_conv;
18472         val_conv.inner = (void*)(val & (~1));
18473         val_conv.is_owned = (val & 1) || (val == 0);
18474         val_conv = DirectionalChannelInfo_clone(&val_conv);
18475         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
18476 }
18477
18478 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
18479         LDKChannelInfo this_ptr_conv;
18480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18481         this_ptr_conv.is_owned = false;
18482         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
18483         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18484         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18485         long ret_ref = (long)ret_var.inner;
18486         if (ret_var.is_owned) {
18487                 ret_ref |= 1;
18488         }
18489         return ret_ref;
18490 }
18491
18492 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
18493         LDKChannelInfo this_ptr_conv;
18494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18495         this_ptr_conv.is_owned = false;
18496         LDKChannelAnnouncement val_conv;
18497         val_conv.inner = (void*)(val & (~1));
18498         val_conv.is_owned = (val & 1) || (val == 0);
18499         val_conv = ChannelAnnouncement_clone(&val_conv);
18500         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
18501 }
18502
18503 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
18504         LDKChannelInfo orig_conv;
18505         orig_conv.inner = (void*)(orig & (~1));
18506         orig_conv.is_owned = false;
18507         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
18508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18510         long ret_ref = (long)ret_var.inner;
18511         if (ret_var.is_owned) {
18512                 ret_ref |= 1;
18513         }
18514         return ret_ref;
18515 }
18516
18517 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
18518         LDKChannelInfo obj_conv;
18519         obj_conv.inner = (void*)(obj & (~1));
18520         obj_conv.is_owned = false;
18521         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
18522         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18523         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18524         CVec_u8Z_free(ret_var);
18525         return ret_arr;
18526 }
18527
18528 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
18529         LDKu8slice ser_ref;
18530         ser_ref.datalen = *((uint32_t*)ser);
18531         ser_ref.data = (int8_t*)(ser + 4);
18532         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18533         *ret_conv = ChannelInfo_read(ser_ref);
18534         return (long)ret_conv;
18535 }
18536
18537 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
18538         LDKRoutingFees this_obj_conv;
18539         this_obj_conv.inner = (void*)(this_obj & (~1));
18540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18541         RoutingFees_free(this_obj_conv);
18542 }
18543
18544 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
18545         LDKRoutingFees this_ptr_conv;
18546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18547         this_ptr_conv.is_owned = false;
18548         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
18549         return ret_val;
18550 }
18551
18552 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
18553         LDKRoutingFees this_ptr_conv;
18554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18555         this_ptr_conv.is_owned = false;
18556         RoutingFees_set_base_msat(&this_ptr_conv, val);
18557 }
18558
18559 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
18560         LDKRoutingFees this_ptr_conv;
18561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18562         this_ptr_conv.is_owned = false;
18563         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
18564         return ret_val;
18565 }
18566
18567 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
18568         LDKRoutingFees this_ptr_conv;
18569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18570         this_ptr_conv.is_owned = false;
18571         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
18572 }
18573
18574 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
18575         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
18576         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18577         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18578         long ret_ref = (long)ret_var.inner;
18579         if (ret_var.is_owned) {
18580                 ret_ref |= 1;
18581         }
18582         return ret_ref;
18583 }
18584
18585 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
18586         LDKRoutingFees orig_conv;
18587         orig_conv.inner = (void*)(orig & (~1));
18588         orig_conv.is_owned = false;
18589         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
18590         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18591         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18592         long ret_ref = (long)ret_var.inner;
18593         if (ret_var.is_owned) {
18594                 ret_ref |= 1;
18595         }
18596         return ret_ref;
18597 }
18598
18599 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
18600         LDKu8slice ser_ref;
18601         ser_ref.datalen = *((uint32_t*)ser);
18602         ser_ref.data = (int8_t*)(ser + 4);
18603         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18604         *ret_conv = RoutingFees_read(ser_ref);
18605         return (long)ret_conv;
18606 }
18607
18608 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
18609         LDKRoutingFees obj_conv;
18610         obj_conv.inner = (void*)(obj & (~1));
18611         obj_conv.is_owned = false;
18612         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
18613         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18614         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18615         CVec_u8Z_free(ret_var);
18616         return ret_arr;
18617 }
18618
18619 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
18620         LDKNodeAnnouncementInfo this_obj_conv;
18621         this_obj_conv.inner = (void*)(this_obj & (~1));
18622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18623         NodeAnnouncementInfo_free(this_obj_conv);
18624 }
18625
18626 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
18627         LDKNodeAnnouncementInfo this_ptr_conv;
18628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18629         this_ptr_conv.is_owned = false;
18630         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
18631         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18632         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18633         long ret_ref = (long)ret_var.inner;
18634         if (ret_var.is_owned) {
18635                 ret_ref |= 1;
18636         }
18637         return ret_ref;
18638 }
18639
18640 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
18641         LDKNodeAnnouncementInfo this_ptr_conv;
18642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18643         this_ptr_conv.is_owned = false;
18644         LDKNodeFeatures val_conv;
18645         val_conv.inner = (void*)(val & (~1));
18646         val_conv.is_owned = (val & 1) || (val == 0);
18647         val_conv = NodeFeatures_clone(&val_conv);
18648         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
18649 }
18650
18651 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
18652         LDKNodeAnnouncementInfo this_ptr_conv;
18653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18654         this_ptr_conv.is_owned = false;
18655         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
18656         return ret_val;
18657 }
18658
18659 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
18660         LDKNodeAnnouncementInfo this_ptr_conv;
18661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18662         this_ptr_conv.is_owned = false;
18663         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
18664 }
18665
18666 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
18667         LDKNodeAnnouncementInfo this_ptr_conv;
18668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18669         this_ptr_conv.is_owned = false;
18670         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
18671         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
18672         return ret_arr;
18673 }
18674
18675 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
18676         LDKNodeAnnouncementInfo this_ptr_conv;
18677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18678         this_ptr_conv.is_owned = false;
18679         LDKThreeBytes val_ref;
18680         CHECK(*((uint32_t*)val) == 3);
18681         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
18682         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
18683 }
18684
18685 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
18686         LDKNodeAnnouncementInfo this_ptr_conv;
18687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18688         this_ptr_conv.is_owned = false;
18689         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18690         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
18691         return ret_arr;
18692 }
18693
18694 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
18695         LDKNodeAnnouncementInfo this_ptr_conv;
18696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18697         this_ptr_conv.is_owned = false;
18698         LDKThirtyTwoBytes val_ref;
18699         CHECK(*((uint32_t*)val) == 32);
18700         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18701         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
18702 }
18703
18704 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
18705         LDKNodeAnnouncementInfo this_ptr_conv;
18706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18707         this_ptr_conv.is_owned = false;
18708         LDKCVec_NetAddressZ val_constr;
18709         val_constr.datalen = *((uint32_t*)val);
18710         if (val_constr.datalen > 0)
18711                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18712         else
18713                 val_constr.data = NULL;
18714         uint32_t* val_vals = (uint32_t*)(val + 4);
18715         for (size_t m = 0; m < val_constr.datalen; m++) {
18716                 uint32_t val_conv_12 = val_vals[m];
18717                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18718                 FREE((void*)val_conv_12);
18719                 val_constr.data[m] = val_conv_12_conv;
18720         }
18721         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
18722 }
18723
18724 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
18725         LDKNodeAnnouncementInfo this_ptr_conv;
18726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18727         this_ptr_conv.is_owned = false;
18728         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
18729         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18730         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18731         long ret_ref = (long)ret_var.inner;
18732         if (ret_var.is_owned) {
18733                 ret_ref |= 1;
18734         }
18735         return ret_ref;
18736 }
18737
18738 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
18739         LDKNodeAnnouncementInfo this_ptr_conv;
18740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18741         this_ptr_conv.is_owned = false;
18742         LDKNodeAnnouncement val_conv;
18743         val_conv.inner = (void*)(val & (~1));
18744         val_conv.is_owned = (val & 1) || (val == 0);
18745         val_conv = NodeAnnouncement_clone(&val_conv);
18746         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
18747 }
18748
18749 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) {
18750         LDKNodeFeatures features_arg_conv;
18751         features_arg_conv.inner = (void*)(features_arg & (~1));
18752         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
18753         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
18754         LDKThreeBytes rgb_arg_ref;
18755         CHECK(*((uint32_t*)rgb_arg) == 3);
18756         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
18757         LDKThirtyTwoBytes alias_arg_ref;
18758         CHECK(*((uint32_t*)alias_arg) == 32);
18759         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
18760         LDKCVec_NetAddressZ addresses_arg_constr;
18761         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
18762         if (addresses_arg_constr.datalen > 0)
18763                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18764         else
18765                 addresses_arg_constr.data = NULL;
18766         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
18767         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
18768                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
18769                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
18770                 FREE((void*)addresses_arg_conv_12);
18771                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
18772         }
18773         LDKNodeAnnouncement announcement_message_arg_conv;
18774         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
18775         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
18776         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
18777         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
18778         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18779         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18780         long ret_ref = (long)ret_var.inner;
18781         if (ret_var.is_owned) {
18782                 ret_ref |= 1;
18783         }
18784         return ret_ref;
18785 }
18786
18787 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
18788         LDKNodeAnnouncementInfo orig_conv;
18789         orig_conv.inner = (void*)(orig & (~1));
18790         orig_conv.is_owned = false;
18791         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
18792         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18793         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18794         long ret_ref = (long)ret_var.inner;
18795         if (ret_var.is_owned) {
18796                 ret_ref |= 1;
18797         }
18798         return ret_ref;
18799 }
18800
18801 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
18802         LDKNodeAnnouncementInfo obj_conv;
18803         obj_conv.inner = (void*)(obj & (~1));
18804         obj_conv.is_owned = false;
18805         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
18806         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18807         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18808         CVec_u8Z_free(ret_var);
18809         return ret_arr;
18810 }
18811
18812 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
18813         LDKu8slice ser_ref;
18814         ser_ref.datalen = *((uint32_t*)ser);
18815         ser_ref.data = (int8_t*)(ser + 4);
18816         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18817         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
18818         return (long)ret_conv;
18819 }
18820
18821 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
18822         LDKNodeInfo this_obj_conv;
18823         this_obj_conv.inner = (void*)(this_obj & (~1));
18824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18825         NodeInfo_free(this_obj_conv);
18826 }
18827
18828 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
18829         LDKNodeInfo this_ptr_conv;
18830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18831         this_ptr_conv.is_owned = false;
18832         LDKCVec_u64Z val_constr;
18833         val_constr.datalen = *((uint32_t*)val);
18834         if (val_constr.datalen > 0)
18835                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18836         else
18837                 val_constr.data = NULL;
18838         int64_t* val_vals = (int64_t*)(val + 4);
18839         for (size_t i = 0; i < val_constr.datalen; i++) {
18840                 int64_t val_conv_8 = val_vals[i];
18841                 val_constr.data[i] = val_conv_8;
18842         }
18843         NodeInfo_set_channels(&this_ptr_conv, val_constr);
18844 }
18845
18846 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
18847         LDKNodeInfo this_ptr_conv;
18848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18849         this_ptr_conv.is_owned = false;
18850         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
18851         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18852         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18853         long ret_ref = (long)ret_var.inner;
18854         if (ret_var.is_owned) {
18855                 ret_ref |= 1;
18856         }
18857         return ret_ref;
18858 }
18859
18860 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
18861         LDKNodeInfo this_ptr_conv;
18862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18863         this_ptr_conv.is_owned = false;
18864         LDKRoutingFees val_conv;
18865         val_conv.inner = (void*)(val & (~1));
18866         val_conv.is_owned = (val & 1) || (val == 0);
18867         val_conv = RoutingFees_clone(&val_conv);
18868         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
18869 }
18870
18871 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
18872         LDKNodeInfo this_ptr_conv;
18873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18874         this_ptr_conv.is_owned = false;
18875         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
18876         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18877         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18878         long ret_ref = (long)ret_var.inner;
18879         if (ret_var.is_owned) {
18880                 ret_ref |= 1;
18881         }
18882         return ret_ref;
18883 }
18884
18885 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
18886         LDKNodeInfo this_ptr_conv;
18887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18888         this_ptr_conv.is_owned = false;
18889         LDKNodeAnnouncementInfo val_conv;
18890         val_conv.inner = (void*)(val & (~1));
18891         val_conv.is_owned = (val & 1) || (val == 0);
18892         val_conv = NodeAnnouncementInfo_clone(&val_conv);
18893         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
18894 }
18895
18896 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
18897         LDKCVec_u64Z channels_arg_constr;
18898         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
18899         if (channels_arg_constr.datalen > 0)
18900                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18901         else
18902                 channels_arg_constr.data = NULL;
18903         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
18904         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
18905                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
18906                 channels_arg_constr.data[i] = channels_arg_conv_8;
18907         }
18908         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
18909         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
18910         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
18911         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
18912         LDKNodeAnnouncementInfo announcement_info_arg_conv;
18913         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
18914         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
18915         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
18916         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
18917         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18918         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18919         long ret_ref = (long)ret_var.inner;
18920         if (ret_var.is_owned) {
18921                 ret_ref |= 1;
18922         }
18923         return ret_ref;
18924 }
18925
18926 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
18927         LDKNodeInfo orig_conv;
18928         orig_conv.inner = (void*)(orig & (~1));
18929         orig_conv.is_owned = false;
18930         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
18931         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18932         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18933         long ret_ref = (long)ret_var.inner;
18934         if (ret_var.is_owned) {
18935                 ret_ref |= 1;
18936         }
18937         return ret_ref;
18938 }
18939
18940 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
18941         LDKNodeInfo obj_conv;
18942         obj_conv.inner = (void*)(obj & (~1));
18943         obj_conv.is_owned = false;
18944         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
18945         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18946         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18947         CVec_u8Z_free(ret_var);
18948         return ret_arr;
18949 }
18950
18951 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
18952         LDKu8slice ser_ref;
18953         ser_ref.datalen = *((uint32_t*)ser);
18954         ser_ref.data = (int8_t*)(ser + 4);
18955         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18956         *ret_conv = NodeInfo_read(ser_ref);
18957         return (long)ret_conv;
18958 }
18959
18960 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
18961         LDKNetworkGraph obj_conv;
18962         obj_conv.inner = (void*)(obj & (~1));
18963         obj_conv.is_owned = false;
18964         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
18965         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18966         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18967         CVec_u8Z_free(ret_var);
18968         return ret_arr;
18969 }
18970
18971 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
18972         LDKu8slice ser_ref;
18973         ser_ref.datalen = *((uint32_t*)ser);
18974         ser_ref.data = (int8_t*)(ser + 4);
18975         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18976         *ret_conv = NetworkGraph_read(ser_ref);
18977         return (long)ret_conv;
18978 }
18979
18980 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
18981         LDKThirtyTwoBytes genesis_hash_ref;
18982         CHECK(*((uint32_t*)genesis_hash) == 32);
18983         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
18984         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
18985         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18986         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18987         long ret_ref = (long)ret_var.inner;
18988         if (ret_var.is_owned) {
18989                 ret_ref |= 1;
18990         }
18991         return ret_ref;
18992 }
18993
18994 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
18995         LDKNetworkGraph this_arg_conv;
18996         this_arg_conv.inner = (void*)(this_arg & (~1));
18997         this_arg_conv.is_owned = false;
18998         LDKNodeAnnouncement msg_conv;
18999         msg_conv.inner = (void*)(msg & (~1));
19000         msg_conv.is_owned = false;
19001         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19002         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
19003         return (long)ret_conv;
19004 }
19005
19006 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
19007         LDKNetworkGraph this_arg_conv;
19008         this_arg_conv.inner = (void*)(this_arg & (~1));
19009         this_arg_conv.is_owned = false;
19010         LDKUnsignedNodeAnnouncement msg_conv;
19011         msg_conv.inner = (void*)(msg & (~1));
19012         msg_conv.is_owned = false;
19013         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19014         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
19015         return (long)ret_conv;
19016 }
19017
19018 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
19019         LDKNetworkGraph this_arg_conv;
19020         this_arg_conv.inner = (void*)(this_arg & (~1));
19021         this_arg_conv.is_owned = false;
19022         LDKChannelAnnouncement msg_conv;
19023         msg_conv.inner = (void*)(msg & (~1));
19024         msg_conv.is_owned = false;
19025         LDKAccess *chain_access_conv_ptr = NULL;
19026         if (chain_access != 0) {
19027                 LDKAccess chain_access_conv;
19028                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19029                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19030                 *chain_access_conv_ptr = chain_access_conv;
19031         }
19032         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19033         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
19034         return (long)ret_conv;
19035 }
19036
19037 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
19038         LDKNetworkGraph this_arg_conv;
19039         this_arg_conv.inner = (void*)(this_arg & (~1));
19040         this_arg_conv.is_owned = false;
19041         LDKUnsignedChannelAnnouncement msg_conv;
19042         msg_conv.inner = (void*)(msg & (~1));
19043         msg_conv.is_owned = false;
19044         LDKAccess *chain_access_conv_ptr = NULL;
19045         if (chain_access != 0) {
19046                 LDKAccess chain_access_conv;
19047                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
19048                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
19049                 *chain_access_conv_ptr = chain_access_conv;
19050         }
19051         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19052         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
19053         return (long)ret_conv;
19054 }
19055
19056 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
19057         LDKNetworkGraph this_arg_conv;
19058         this_arg_conv.inner = (void*)(this_arg & (~1));
19059         this_arg_conv.is_owned = false;
19060         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
19061 }
19062
19063 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
19064         LDKNetworkGraph this_arg_conv;
19065         this_arg_conv.inner = (void*)(this_arg & (~1));
19066         this_arg_conv.is_owned = false;
19067         LDKChannelUpdate msg_conv;
19068         msg_conv.inner = (void*)(msg & (~1));
19069         msg_conv.is_owned = false;
19070         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19071         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
19072         return (long)ret_conv;
19073 }
19074
19075 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
19076         LDKNetworkGraph this_arg_conv;
19077         this_arg_conv.inner = (void*)(this_arg & (~1));
19078         this_arg_conv.is_owned = false;
19079         LDKUnsignedChannelUpdate msg_conv;
19080         msg_conv.inner = (void*)(msg & (~1));
19081         msg_conv.is_owned = false;
19082         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19083         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
19084         return (long)ret_conv;
19085 }
19086