Bindings updates
[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 // Always run a, then assert it is true:
17 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
18 // Assert a is true or do nothing
19 #define CHECK(a) DO_ASSERT(a)
20
21 // Running a leak check across all the allocations and frees of the JDK is a mess,
22 // so instead we implement our own naive leak checker here, relying on the -wrap
23 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
24 // and free'd in Rust or C across the generated bindings shared library.
25
26 #define BT_MAX 128
27 typedef struct allocation {
28         struct allocation* next;
29         void* ptr;
30         const char* struct_name;
31 } allocation;
32 static allocation* allocation_ll = NULL;
33
34 void* __real_malloc(size_t len);
35 void* __real_calloc(size_t nmemb, size_t len);
36 static void new_allocation(void* res, const char* struct_name) {
37         allocation* new_alloc = __real_malloc(sizeof(allocation));
38         new_alloc->ptr = res;
39         new_alloc->struct_name = struct_name;
40         new_alloc->next = allocation_ll;
41         allocation_ll = new_alloc;
42 }
43 static void* MALLOC(size_t len, const char* struct_name) {
44         void* res = __real_malloc(len);
45         new_allocation(res, struct_name);
46         return res;
47 }
48 void __real_free(void* ptr);
49 static void alloc_freed(void* ptr) {
50         allocation* p = NULL;
51         allocation* it = allocation_ll;
52         while (it->ptr != ptr) {
53                 p = it; it = it->next;
54                 if (it == NULL) {
55                         //XXX: fprintf(stderr, "Tried to free unknown pointer %p\n", ptr);
56                         return; // addrsan should catch malloc-unknown and print more info than we have
57                 }
58         }
59         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
60         DO_ASSERT(it->ptr == ptr);
61         __real_free(it);
62 }
63 static void FREE(void* ptr) {
64         if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
65         alloc_freed(ptr);
66         __real_free(ptr);
67 }
68
69 void* __wrap_malloc(size_t len) {
70         void* res = __real_malloc(len);
71         new_allocation(res, "malloc call");
72         return res;
73 }
74 void* __wrap_calloc(size_t nmemb, size_t len) {
75         void* res = __real_calloc(nmemb, len);
76         new_allocation(res, "calloc call");
77         return res;
78 }
79 void __wrap_free(void* ptr) {
80         if (ptr == NULL) return;
81         alloc_freed(ptr);
82         __real_free(ptr);
83 }
84
85 void* __real_realloc(void* ptr, size_t newlen);
86 void* __wrap_realloc(void* ptr, size_t len) {
87         if (ptr != NULL) alloc_freed(ptr);
88         void* res = __real_realloc(ptr, len);
89         new_allocation(res, "realloc call");
90         return res;
91 }
92 void __wrap_reallocarray(void* ptr, size_t new_sz) {
93         // Rust doesn't seem to use reallocarray currently
94         DO_ASSERT(false);
95 }
96
97 void __attribute__((destructor)) check_leaks() {
98         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
99                 //XXX: fprintf(stderr, "%s %p remains\n", a->struct_name, a->ptr);
100         }
101         DO_ASSERT(allocation_ll == NULL);
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
110
111 typedef uint32_t int64_tArray;
112 typedef uint32_t int8_tArray;
113 typedef uint32_t uint32_tArray;
114 typedef uint32_t ptrArray;
115 typedef uint32_t jstring;
116
117 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
118         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
119         elems[0] = arr_len;
120         return (uint32_t)elems;
121 }
122
123 jstring str_ref_to_ts(const char* chars, size_t len) {
124         char* err_buf = MALLOC(len + 4, "str conv buf");
125         *((uint32_t*)err_buf) = len;
126         memcpy(err_buf + 4, chars, len);
127         return (uint32_t) err_buf;
128 }
129
130 typedef bool jboolean;
131
132 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
133         return (uint32_t)MALLOC(size, "JS-Called malloc");
134 }
135 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
136         FREE((void*)ptr);
137 }
138 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
139 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKAccessError_UnknownChain;
142                 case 1: return LDKAccessError_UnknownTx;
143         }
144         abort();
145 }
146 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
147         switch (val) {
148                 case LDKAccessError_UnknownChain: return 0;
149                 case LDKAccessError_UnknownTx: return 1;
150                 default: abort();
151         }
152 }
153 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
156                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
157         }
158         abort();
159 }
160 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
161         switch (val) {
162                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
163                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
164                 default: abort();
165         }
166 }
167 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
168         switch (ord) {
169                 case 0: return LDKConfirmationTarget_Background;
170                 case 1: return LDKConfirmationTarget_Normal;
171                 case 2: return LDKConfirmationTarget_HighPriority;
172         }
173         abort();
174 }
175 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
176         switch (val) {
177                 case LDKConfirmationTarget_Background: return 0;
178                 case LDKConfirmationTarget_Normal: return 1;
179                 case LDKConfirmationTarget_HighPriority: return 2;
180                 default: abort();
181         }
182 }
183 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
184         switch (ord) {
185                 case 0: return LDKLevel_Off;
186                 case 1: return LDKLevel_Error;
187                 case 2: return LDKLevel_Warn;
188                 case 3: return LDKLevel_Info;
189                 case 4: return LDKLevel_Debug;
190                 case 5: return LDKLevel_Trace;
191         }
192         abort();
193 }
194 static inline int32_t LDKLevel_to_js(LDKLevel val) {
195         switch (val) {
196                 case LDKLevel_Off: return 0;
197                 case LDKLevel_Error: return 1;
198                 case LDKLevel_Warn: return 2;
199                 case LDKLevel_Info: return 3;
200                 case LDKLevel_Debug: return 4;
201                 case LDKLevel_Trace: return 5;
202                 default: abort();
203         }
204 }
205 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
206         switch (ord) {
207                 case 0: return LDKNetwork_Bitcoin;
208                 case 1: return LDKNetwork_Testnet;
209                 case 2: return LDKNetwork_Regtest;
210         }
211         abort();
212 }
213 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
214         switch (val) {
215                 case LDKNetwork_Bitcoin: return 0;
216                 case LDKNetwork_Testnet: return 1;
217                 case LDKNetwork_Regtest: return 2;
218                 default: abort();
219         }
220 }
221 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
222         switch (ord) {
223                 case 0: return LDKSecp256k1Error_IncorrectSignature;
224                 case 1: return LDKSecp256k1Error_InvalidMessage;
225                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
226                 case 3: return LDKSecp256k1Error_InvalidSignature;
227                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
228                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
229                 case 6: return LDKSecp256k1Error_InvalidTweak;
230                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
231                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
232         }
233         abort();
234 }
235 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
236         switch (val) {
237                 case LDKSecp256k1Error_IncorrectSignature: return 0;
238                 case LDKSecp256k1Error_InvalidMessage: return 1;
239                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
240                 case LDKSecp256k1Error_InvalidSignature: return 3;
241                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
242                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
243                 case LDKSecp256k1Error_InvalidTweak: return 6;
244                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
245                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
246                 default: abort();
247         }
248 }
249 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
250         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
251         ret->datalen = *((uint32_t*)elems);
252         if (ret->datalen == 0) {
253                 ret->data = NULL;
254         } else {
255                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
256                 int8_t *java_elems = (int8_t*)(elems + 4);
257                 for (size_t i = 0; i < ret->datalen; i++) {
258                         ret->data[i] = java_elems[i];
259                 }
260         }
261         return (long)ret;
262 }
263 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
264         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
265         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
266         return ret;
267 }
268 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_new(int64_t a, int64_t b) {
269         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
270         ret->a = a;
271         ret->b = b;
272         return (long)ret;
273 }
274 static inline LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const LDKC2Tuple_u64u64Z *orig) {
275         LDKC2Tuple_u64u64Z ret = {
276                 .a = orig->a,
277                 .b = orig->b,
278         };
279         return ret;
280 }
281 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_a(uint32_t ptr) {
282         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
283         return tuple->a;
284 }
285 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_b(uint32_t ptr) {
286         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
287         return tuple->b;
288 }
289 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
290         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
291         switch(obj->tag) {
292                 case LDKSpendableOutputDescriptor_StaticOutput: {
293                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
294                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
295                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
296                         long outpoint_ref = (long)outpoint_var.inner & ~1;
297                         long output_ref = (long)&obj->static_output.output;
298                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
299                 }
300                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
301                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
302                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
303                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
304                         long outpoint_ref = (long)outpoint_var.inner & ~1;
305                         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
306                         memcpy((uint8_t*)(per_commitment_point_arr + 4), obj->dynamic_output_p2wsh.per_commitment_point.compressed_form, 33);
307                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
308                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
309                         int8_tArray revocation_pubkey_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
310                         memcpy((uint8_t*)(revocation_pubkey_arr + 4), obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form, 33);
311                         return 0 /* LDKSpendableOutputDescriptor - DynamicOutputP2WSH */; (void) outpoint_ref; (void) per_commitment_point_arr; (void) obj->dynamic_output_p2wsh.to_self_delay; (void) (long)output_ref; (void) key_derivation_params_ref; (void) revocation_pubkey_arr;
312                 }
313                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
314                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
315                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
316                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
317                         long outpoint_ref = (long)outpoint_var.inner & ~1;
318                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
319                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
320                         return 0 /* LDKSpendableOutputDescriptor - StaticOutputCounterpartyPayment */; (void) outpoint_ref; (void) (long)output_ref; (void) key_derivation_params_ref;
321                 }
322                 default: abort();
323         }
324 }
325 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
326         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
327         ret->datalen = *((uint32_t*)elems);
328         if (ret->datalen == 0) {
329                 ret->data = NULL;
330         } else {
331                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
332                 uint32_t *java_elems = (uint32_t*)(elems + 4);
333                 for (size_t i = 0; i < ret->datalen; i++) {
334                         uint32_t arr_elem = java_elems[i];
335                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
336                         FREE((void*)arr_elem);
337                         ret->data[i] = arr_elem_conv;
338                 }
339         }
340         return (long)ret;
341 }
342 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
343         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
344         for (size_t i = 0; i < ret.datalen; i++) {
345                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
346         }
347         return ret;
348 }
349 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
350         LDKErrorAction *obj = (LDKErrorAction*)ptr;
351         switch(obj->tag) {
352                 case LDKErrorAction_DisconnectPeer: {
353                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
354                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
355                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
356                         long msg_ref = (long)msg_var.inner & ~1;
357                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
358                 }
359                 case LDKErrorAction_IgnoreError: {
360                         return 0 /* LDKErrorAction - IgnoreError */;
361                 }
362                 case LDKErrorAction_SendErrorMessage: {
363                         LDKErrorMessage msg_var = obj->send_error_message.msg;
364                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
365                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
366                         long msg_ref = (long)msg_var.inner & ~1;
367                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
368                 }
369                 default: abort();
370         }
371 }
372 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
373         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
374         switch(obj->tag) {
375                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
376                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
377                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
378                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
379                         long msg_ref = (long)msg_var.inner & ~1;
380                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
381                 }
382                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
383                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
384                 }
385                 case LDKHTLCFailChannelUpdate_NodeFailure: {
386                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
387                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
388                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
389                 }
390                 default: abort();
391         }
392 }
393 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
394         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
395         switch(obj->tag) {
396                 case LDKMessageSendEvent_SendAcceptChannel: {
397                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
398                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
399                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
400                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
401                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
402                         long msg_ref = (long)msg_var.inner & ~1;
403                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
404                 }
405                 case LDKMessageSendEvent_SendOpenChannel: {
406                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
407                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
408                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
409                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
410                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
411                         long msg_ref = (long)msg_var.inner & ~1;
412                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
413                 }
414                 case LDKMessageSendEvent_SendFundingCreated: {
415                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
416                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
417                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
418                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
419                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
420                         long msg_ref = (long)msg_var.inner & ~1;
421                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
422                 }
423                 case LDKMessageSendEvent_SendFundingSigned: {
424                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
425                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
426                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
427                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
428                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
429                         long msg_ref = (long)msg_var.inner & ~1;
430                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
431                 }
432                 case LDKMessageSendEvent_SendFundingLocked: {
433                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
434                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
435                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
436                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
437                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
438                         long msg_ref = (long)msg_var.inner & ~1;
439                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
440                 }
441                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
442                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
443                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
444                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
445                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
446                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
447                         long msg_ref = (long)msg_var.inner & ~1;
448                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
449                 }
450                 case LDKMessageSendEvent_UpdateHTLCs: {
451                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
452                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
453                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
454                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
455                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
456                         long updates_ref = (long)updates_var.inner & ~1;
457                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
458                 }
459                 case LDKMessageSendEvent_SendRevokeAndACK: {
460                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
461                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
462                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
463                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
464                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
465                         long msg_ref = (long)msg_var.inner & ~1;
466                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
467                 }
468                 case LDKMessageSendEvent_SendClosingSigned: {
469                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
470                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
471                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
472                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
473                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
474                         long msg_ref = (long)msg_var.inner & ~1;
475                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
476                 }
477                 case LDKMessageSendEvent_SendShutdown: {
478                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
479                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
480                         LDKShutdown msg_var = obj->send_shutdown.msg;
481                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
482                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
483                         long msg_ref = (long)msg_var.inner & ~1;
484                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
485                 }
486                 case LDKMessageSendEvent_SendChannelReestablish: {
487                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
488                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
489                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
490                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
491                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
492                         long msg_ref = (long)msg_var.inner & ~1;
493                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
494                 }
495                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
496                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.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                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
501                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503                         long update_msg_ref = (long)update_msg_var.inner & ~1;
504                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
505                 }
506                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
507                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
508                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
509                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
510                         long msg_ref = (long)msg_var.inner & ~1;
511                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
512                 }
513                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
514                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.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 - BroadcastChannelUpdate */; (void) msg_ref;
519                 }
520                 case LDKMessageSendEvent_HandleError: {
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->handle_error.node_id.compressed_form, 33);
523                         long action_ref = (long)&obj->handle_error.action;
524                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
525                 }
526                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
527                         long update_ref = (long)&obj->payment_failure_network_update.update;
528                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
529                 }
530                 case LDKMessageSendEvent_SendChannelRangeQuery: {
531                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
532                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
533                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
534                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
535                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
536                         long msg_ref = (long)msg_var.inner & ~1;
537                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
538                 }
539                 case LDKMessageSendEvent_SendShortIdsQuery: {
540                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
541                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
542                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
543                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
544                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
545                         long msg_ref = (long)msg_var.inner & ~1;
546                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
547                 }
548                 default: abort();
549         }
550 }
551 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
552         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
553         ret->datalen = *((uint32_t*)elems);
554         if (ret->datalen == 0) {
555                 ret->data = NULL;
556         } else {
557                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
558                 uint32_t *java_elems = (uint32_t*)(elems + 4);
559                 for (size_t i = 0; i < ret->datalen; i++) {
560                         uint32_t arr_elem = java_elems[i];
561                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
562                         FREE((void*)arr_elem);
563                         ret->data[i] = arr_elem_conv;
564                 }
565         }
566         return (long)ret;
567 }
568 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
569         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
570         for (size_t i = 0; i < ret.datalen; i++) {
571                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
572         }
573         return ret;
574 }
575 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
576         LDKEvent *obj = (LDKEvent*)ptr;
577         switch(obj->tag) {
578                 case LDKEvent_FundingGenerationReady: {
579                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
580                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
581                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
582                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
583                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
584                         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;
585                 }
586                 case LDKEvent_FundingBroadcastSafe: {
587                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
588                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
589                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
590                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
591                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
592                 }
593                 case LDKEvent_PaymentReceived: {
594                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
595                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
596                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
597                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
598                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
599                 }
600                 case LDKEvent_PaymentSent: {
601                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
602                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
603                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
604                 }
605                 case LDKEvent_PaymentFailed: {
606                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
607                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
608                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
609                 }
610                 case LDKEvent_PendingHTLCsForwardable: {
611                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
612                 }
613                 case LDKEvent_SpendableOutputs: {
614                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
615                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
616                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
617                         for (size_t b = 0; b < outputs_var.datalen; b++) {
618                                 long arr_conv_27_ref = (long)&outputs_var.data[b];
619                                 outputs_arr_ptr[b] = arr_conv_27_ref;
620                         }
621                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
622                 }
623                 default: abort();
624         }
625 }
626 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
627         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
628         ret->datalen = *((uint32_t*)elems);
629         if (ret->datalen == 0) {
630                 ret->data = NULL;
631         } else {
632                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
633                 uint32_t *java_elems = (uint32_t*)(elems + 4);
634                 for (size_t i = 0; i < ret->datalen; i++) {
635                         uint32_t arr_elem = java_elems[i];
636                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
637                         FREE((void*)arr_elem);
638                         ret->data[i] = arr_elem_conv;
639                 }
640         }
641         return (long)ret;
642 }
643 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
644         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
645         for (size_t i = 0; i < ret.datalen; i++) {
646                 ret.data[i] = Event_clone(&orig->data[i]);
647         }
648         return ret;
649 }
650 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
651         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
652         ret->a = a;
653         LDKTransaction b_ref;
654         b_ref.datalen = *((uint32_t*)b);
655         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
656         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
657         b_ref.data_is_owned = false;
658         ret->b = b_ref;
659         return (long)ret;
660 }
661 intptr_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
662         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
663         return tuple->a;
664 }
665 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
666         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
667         LDKTransaction b_var = tuple->b;
668         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
669         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
670         return b_arr;
671 }
672 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
673         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
674         ret->datalen = *((uint32_t*)elems);
675         if (ret->datalen == 0) {
676                 ret->data = NULL;
677         } else {
678                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
679                 uint32_t *java_elems = (uint32_t*)(elems + 4);
680                 for (size_t i = 0; i < ret->datalen; i++) {
681                         uint32_t arr_elem = java_elems[i];
682                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_elem;
683                         FREE((void*)arr_elem);
684                         ret->data[i] = arr_elem_conv;
685                 }
686         }
687         return (long)ret;
688 }
689 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
690         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
691 }
692 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
693         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
694         CHECK(val->result_ok);
695         return *val->contents.result;
696 }
697 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
698         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
699         CHECK(!val->result_ok);
700         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
701         return err_conv;
702 }
703 static inline LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const LDKCResult_NoneChannelMonitorUpdateErrZ *orig) {
704         LDKCResult_NoneChannelMonitorUpdateErrZ res = { .result_ok = orig->result_ok };
705         if (orig->result_ok) {
706                 res.contents.result = NULL;
707         } else {
708                 LDKChannelMonitorUpdateErr* contents = MALLOC(sizeof(LDKChannelMonitorUpdateErr), "LDKChannelMonitorUpdateErr result Err clone");
709                 *contents = ChannelMonitorUpdateErr_clone(orig->contents.err);
710                 res.contents.err = contents;
711         }
712         return res;
713 }
714 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
715         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
716         ret->datalen = *((uint32_t*)elems);
717         if (ret->datalen == 0) {
718                 ret->data = NULL;
719         } else {
720                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
721                 uint32_t *java_elems = (uint32_t*)(elems + 4);
722                 for (size_t i = 0; i < ret->datalen; i++) {
723                         uint32_t arr_elem = java_elems[i];
724                         LDKMonitorEvent arr_elem_conv;
725                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
726                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
727                         if (arr_elem_conv.inner != NULL)
728                                 arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
729                         ret->data[i] = arr_elem_conv;
730                 }
731         }
732         return (long)ret;
733 }
734 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
735         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
736         for (size_t i = 0; i < ret.datalen; i++) {
737                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
738         }
739         return ret;
740 }
741 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
742         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
743 }
744 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
745         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
746         CHECK(val->result_ok);
747         LDKChannelMonitorUpdate res_var = (*val->contents.result);
748         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
749         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
750         long res_ref = (long)res_var.inner & ~1;
751         return res_ref;
752 }
753 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
754         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
755         CHECK(!val->result_ok);
756         LDKDecodeError err_var = (*val->contents.err);
757         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
758         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
759         long err_ref = (long)err_var.inner & ~1;
760         return err_ref;
761 }
762 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
763         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
764 }
765 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
766         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
767         CHECK(val->result_ok);
768         return *val->contents.result;
769 }
770 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
771         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
772         CHECK(!val->result_ok);
773         LDKMonitorUpdateError err_var = (*val->contents.err);
774         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
775         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
776         long err_ref = (long)err_var.inner & ~1;
777         return err_ref;
778 }
779 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
780         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
781         LDKOutPoint a_conv;
782         a_conv.inner = (void*)(a & (~1));
783         a_conv.is_owned = (a & 1) || (a == 0);
784         if (a_conv.inner != NULL)
785                 a_conv = OutPoint_clone(&a_conv);
786         ret->a = a_conv;
787         LDKCVec_u8Z b_ref;
788         b_ref.datalen = *((uint32_t*)b);
789         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
790         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
791         ret->b = b_ref;
792         return (long)ret;
793 }
794 static inline LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const LDKC2Tuple_OutPointScriptZ *orig) {
795         LDKC2Tuple_OutPointScriptZ ret = {
796                 .a = OutPoint_clone(&orig->a),
797                 .b = CVec_u8Z_clone(&orig->b),
798         };
799         return ret;
800 }
801 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
802         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
803         LDKOutPoint a_var = tuple->a;
804         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
805         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
806         long a_ref = (long)a_var.inner & ~1;
807         return a_ref;
808 }
809 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
810         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
811         LDKCVec_u8Z b_var = tuple->b;
812         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
813         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
814         return b_arr;
815 }
816 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
817         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
818         ret->a = a;
819         LDKTxOut b_conv = *(LDKTxOut*)b;
820         FREE((void*)b);
821         ret->b = b_conv;
822         return (long)ret;
823 }
824 static inline LDKC2Tuple_u32TxOutZ C2Tuple_u32TxOutZ_clone(const LDKC2Tuple_u32TxOutZ *orig) {
825         LDKC2Tuple_u32TxOutZ ret = {
826                 .a = orig->a,
827                 .b = TxOut_clone(&orig->b),
828         };
829         return ret;
830 }
831 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
832         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
833         return tuple->a;
834 }
835 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
836         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
837         long b_ref = (long)&tuple->b;
838         return (long)b_ref;
839 }
840 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
841         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
842         ret->datalen = *((uint32_t*)elems);
843         if (ret->datalen == 0) {
844                 ret->data = NULL;
845         } else {
846                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
847                 uint32_t *java_elems = (uint32_t*)(elems + 4);
848                 for (size_t i = 0; i < ret->datalen; i++) {
849                         uint32_t arr_elem = java_elems[i];
850                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)arr_elem;
851                         FREE((void*)arr_elem);
852                         ret->data[i] = arr_elem_conv;
853                 }
854         }
855         return (long)ret;
856 }
857 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
858         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
859         for (size_t i = 0; i < ret.datalen; i++) {
860                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
861         }
862         return ret;
863 }
864 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
865         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
866         LDKThirtyTwoBytes a_ref;
867         CHECK(*((uint32_t*)a) == 32);
868         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
869         ret->a = a_ref;
870         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
871         b_constr.datalen = *((uint32_t*)b);
872         if (b_constr.datalen > 0)
873                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
874         else
875                 b_constr.data = NULL;
876         uint32_t* b_vals = (uint32_t*)(b + 4);
877         for (size_t z = 0; z < b_constr.datalen; z++) {
878                 uint32_t arr_conv_25 = b_vals[z];
879                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
880                 FREE((void*)arr_conv_25);
881                 b_constr.data[z] = arr_conv_25_conv;
882         }
883         ret->b = b_constr;
884         return (long)ret;
885 }
886 static inline LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(const LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *orig) {
887         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ ret = {
888                 .a = ThirtyTwoBytes_clone(&orig->a),
889                 .b = CVec_C2Tuple_u32TxOutZZ_clone(&orig->b),
890         };
891         return ret;
892 }
893 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
894         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
895         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
896         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
897         return a_arr;
898 }
899 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
900         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
901         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
902         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
903         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
904         for (size_t z = 0; z < b_var.datalen; z++) {
905                 long arr_conv_25_ref = (long)&b_var.data[z];
906                 b_arr_ptr[z] = arr_conv_25_ref;
907         }
908         return b_arr;
909 }
910 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
911         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
912         ret->datalen = *((uint32_t*)elems);
913         if (ret->datalen == 0) {
914                 ret->data = NULL;
915         } else {
916                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
917                 uint32_t *java_elems = (uint32_t*)(elems + 4);
918                 for (size_t i = 0; i < ret->datalen; i++) {
919                         uint32_t arr_elem = java_elems[i];
920                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_elem;
921                         FREE((void*)arr_elem);
922                         ret->data[i] = arr_elem_conv;
923                 }
924         }
925         return (long)ret;
926 }
927 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
928         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
929         for (size_t i = 0; i < ret.datalen; i++) {
930                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
931         }
932         return ret;
933 }
934 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
935         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
936         LDKSignature a_ref;
937         CHECK(*((uint32_t*)a) == 64);
938         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
939         ret->a = a_ref;
940         LDKCVec_SignatureZ b_constr;
941         b_constr.datalen = *((uint32_t*)b);
942         if (b_constr.datalen > 0)
943                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
944         else
945                 b_constr.data = NULL;
946         int8_tArray* b_vals = (int8_tArray*)(b + 4);
947         for (size_t m = 0; m < b_constr.datalen; m++) {
948                 int8_tArray arr_conv_12 = b_vals[m];
949                 LDKSignature arr_conv_12_ref;
950                 CHECK(*((uint32_t*)arr_conv_12) == 64);
951                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
952                 b_constr.data[m] = arr_conv_12_ref;
953         }
954         ret->b = b_constr;
955         return (long)ret;
956 }
957 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
958         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
959         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
960         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
961         return a_arr;
962 }
963 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
964         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
965         LDKCVec_SignatureZ b_var = tuple->b;
966         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
967         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
968         for (size_t m = 0; m < b_var.datalen; m++) {
969                 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
970                 memcpy((uint8_t*)(arr_conv_12_arr + 4), b_var.data[m].compact_form, 64);
971                 b_arr_ptr[m] = arr_conv_12_arr;
972         }
973         return b_arr;
974 }
975 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
976         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
977 }
978 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
979         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
980         CHECK(val->result_ok);
981         long res_ref = (long)&(*val->contents.result);
982         return res_ref;
983 }
984 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
985         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
986         CHECK(!val->result_ok);
987         return *val->contents.err;
988 }
989 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
990         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
991 }
992 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
993         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
994         CHECK(val->result_ok);
995         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
996         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
997         return res_arr;
998 }
999 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1000         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
1001         CHECK(!val->result_ok);
1002         return *val->contents.err;
1003 }
1004 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
1005         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
1006 }
1007 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
1008         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
1009         CHECK(val->result_ok);
1010         LDKCVec_SignatureZ res_var = (*val->contents.result);
1011         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1012         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
1013         for (size_t m = 0; m < res_var.datalen; m++) {
1014                 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1015                 memcpy((uint8_t*)(arr_conv_12_arr + 4), res_var.data[m].compact_form, 64);
1016                 res_arr_ptr[m] = arr_conv_12_arr;
1017         }
1018         return res_arr;
1019 }
1020 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
1021         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
1022         CHECK(!val->result_ok);
1023         return *val->contents.err;
1024 }
1025 typedef struct LDKChannelKeys_JCalls {
1026         atomic_size_t refcnt;
1027         uint32_t get_per_commitment_point_meth;
1028         uint32_t release_commitment_secret_meth;
1029         uint32_t key_derivation_params_meth;
1030         uint32_t sign_counterparty_commitment_meth;
1031         uint32_t sign_holder_commitment_meth;
1032         uint32_t sign_holder_commitment_htlc_transactions_meth;
1033         uint32_t sign_justice_transaction_meth;
1034         uint32_t sign_counterparty_htlc_transaction_meth;
1035         uint32_t sign_closing_transaction_meth;
1036         uint32_t sign_channel_announcement_meth;
1037         uint32_t ready_channel_meth;
1038         uint32_t write_meth;
1039 } LDKChannelKeys_JCalls;
1040 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1041         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1042         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1043                 js_free(j_calls->get_per_commitment_point_meth);
1044                 js_free(j_calls->release_commitment_secret_meth);
1045                 js_free(j_calls->key_derivation_params_meth);
1046                 js_free(j_calls->sign_counterparty_commitment_meth);
1047                 js_free(j_calls->sign_holder_commitment_meth);
1048                 js_free(j_calls->sign_holder_commitment_htlc_transactions_meth);
1049                 js_free(j_calls->sign_justice_transaction_meth);
1050                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1051                 js_free(j_calls->sign_closing_transaction_meth);
1052                 js_free(j_calls->sign_channel_announcement_meth);
1053                 js_free(j_calls->ready_channel_meth);
1054                 js_free(j_calls->write_meth);
1055                 FREE(j_calls);
1056         }
1057 }
1058 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1059         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1060         int8_tArray arg = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1061         LDKPublicKey arg_ref;
1062         CHECK(*((uint32_t*)arg) == 33);
1063         memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
1064         return arg_ref;
1065 }
1066 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1067         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1068         int8_tArray arg = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1069         LDKThirtyTwoBytes arg_ref;
1070         CHECK(*((uint32_t*)arg) == 32);
1071         memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
1072         return arg_ref;
1073 }
1074 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1075         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1076         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)js_invoke_function_0(j_calls->key_derivation_params_meth);
1077         LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)ret;
1078         ret_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)ret);
1079         return ret_conv;
1080 }
1081 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1082         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1083         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1084         if (commitment_tx->inner != NULL)
1085                 commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1086         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1087         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1088         long commitment_tx_ref = (long)commitment_tx_var.inner;
1089         if (commitment_tx_var.is_owned) {
1090                 commitment_tx_ref |= 1;
1091         }
1092         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1093         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret;
1094         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
1095         return ret_conv;
1096 }
1097 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1098         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1099         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1100         if (commitment_tx->inner != NULL)
1101                 commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1102         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1103         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1104         long commitment_tx_ref = (long)commitment_tx_var.inner;
1105         if (commitment_tx_var.is_owned) {
1106                 commitment_tx_ref |= 1;
1107         }
1108         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_meth, commitment_tx_ref);
1109         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1110         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1111         return ret_conv;
1112 }
1113 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1114         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1115         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1116         if (commitment_tx->inner != NULL)
1117                 commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1118         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1119         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1120         long commitment_tx_ref = (long)commitment_tx_var.inner;
1121         if (commitment_tx_var.is_owned) {
1122                 commitment_tx_ref |= 1;
1123         }
1124         LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_htlc_transactions_meth, commitment_tx_ref);
1125         LDKCResult_CVec_SignatureZNoneZ ret_conv = *(LDKCResult_CVec_SignatureZNoneZ*)ret;
1126         ret_conv = CResult_CVec_SignatureZNoneZ_clone((LDKCResult_CVec_SignatureZNoneZ*)ret);
1127         return ret_conv;
1128 }
1129 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) {
1130         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1131         LDKTransaction justice_tx_var = justice_tx;
1132         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1133         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1134         Transaction_free(justice_tx_var);
1135         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1136         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1137         LDKHTLCOutputInCommitment htlc_var = *htlc;
1138         if (htlc->inner != NULL)
1139                 htlc_var = HTLCOutputInCommitment_clone(htlc);
1140         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1141         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1142         long htlc_ref = (long)htlc_var.inner;
1143         if (htlc_var.is_owned) {
1144                 htlc_ref |= 1;
1145         }
1146         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);
1147         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1148         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1149         return ret_conv;
1150 }
1151 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) {
1152         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1153         LDKTransaction htlc_tx_var = htlc_tx;
1154         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1155         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1156         Transaction_free(htlc_tx_var);
1157         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1158         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1159         LDKHTLCOutputInCommitment htlc_var = *htlc;
1160         if (htlc->inner != NULL)
1161                 htlc_var = HTLCOutputInCommitment_clone(htlc);
1162         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1163         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1164         long htlc_ref = (long)htlc_var.inner;
1165         if (htlc_var.is_owned) {
1166                 htlc_ref |= 1;
1167         }
1168         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);
1169         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1170         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1171         return ret_conv;
1172 }
1173 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1174         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1175         LDKTransaction closing_tx_var = closing_tx;
1176         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1177         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1178         Transaction_free(closing_tx_var);
1179         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1180         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1181         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1182         return ret_conv;
1183 }
1184 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1185         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1186         LDKUnsignedChannelAnnouncement msg_var = *msg;
1187         if (msg->inner != NULL)
1188                 msg_var = UnsignedChannelAnnouncement_clone(msg);
1189         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1190         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1191         long msg_ref = (long)msg_var.inner;
1192         if (msg_var.is_owned) {
1193                 msg_ref |= 1;
1194         }
1195         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1196         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1197         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1198         return ret_conv;
1199 }
1200 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1201         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1202         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1203         if (channel_parameters->inner != NULL)
1204                 channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1205         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1206         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1207         long channel_parameters_ref = (long)channel_parameters_var.inner;
1208         if (channel_parameters_var.is_owned) {
1209                 channel_parameters_ref |= 1;
1210         }
1211         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1212 }
1213 LDKCVec_u8Z write_jcall(const void* this_arg) {
1214         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1215         int8_tArray arg = js_invoke_function_0(j_calls->write_meth);
1216         LDKCVec_u8Z arg_ref;
1217         arg_ref.datalen = *((uint32_t*)arg);
1218         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1219         memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1220         return arg_ref;
1221 }
1222 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1223         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1224         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1225         return (void*) this_arg;
1226 }
1227 static inline LDKChannelKeys LDKChannelKeys_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1228         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1229         atomic_init(&calls->refcnt, 1);
1230         //TODO: Assign calls->o from o
1231
1232         LDKChannelPublicKeys pubkeys_conv;
1233         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1234         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1235         if (pubkeys_conv.inner != NULL)
1236                 pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1237
1238         LDKChannelKeys ret = {
1239                 .this_arg = (void*) calls,
1240                 .get_per_commitment_point = get_per_commitment_point_jcall,
1241                 .release_commitment_secret = release_commitment_secret_jcall,
1242                 .key_derivation_params = key_derivation_params_jcall,
1243                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1244                 .sign_holder_commitment = sign_holder_commitment_jcall,
1245                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1246                 .sign_justice_transaction = sign_justice_transaction_jcall,
1247                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1248                 .sign_closing_transaction = sign_closing_transaction_jcall,
1249                 .sign_channel_announcement = sign_channel_announcement_jcall,
1250                 .ready_channel = ready_channel_jcall,
1251                 .clone = LDKChannelKeys_JCalls_clone,
1252                 .write = write_jcall,
1253                 .free = LDKChannelKeys_JCalls_free,
1254                 .pubkeys = pubkeys_conv,
1255                 .set_pubkeys = NULL,
1256         };
1257         return ret;
1258 }
1259 long  __attribute__((visibility("default"))) TS_LDKChannelKeys_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1260         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1261         *res_ptr = LDKChannelKeys_init(o, pubkeys);
1262         return (long)res_ptr;
1263 }
1264 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1265         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1266         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1267         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1268         return arg_arr;
1269 }
1270
1271 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1272         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1273         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1274         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1275         return arg_arr;
1276 }
1277
1278 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_key_derivation_params(uint32_t this_arg) {
1279         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1280         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1281         *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1282         return (long)ret_ref;
1283 }
1284
1285 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1286         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1287         LDKCommitmentTransaction commitment_tx_conv;
1288         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1289         commitment_tx_conv.is_owned = false;
1290         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1291         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1292         return (long)ret_conv;
1293 }
1294
1295 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_holder_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1296         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1297         LDKHolderCommitmentTransaction commitment_tx_conv;
1298         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1299         commitment_tx_conv.is_owned = false;
1300         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1301         *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1302         return (long)ret_conv;
1303 }
1304
1305 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_holder_commitment_htlc_transactions(uint32_t this_arg, uint32_t commitment_tx) {
1306         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1307         LDKHolderCommitmentTransaction commitment_tx_conv;
1308         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1309         commitment_tx_conv.is_owned = false;
1310         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1311         *ret_conv = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &commitment_tx_conv);
1312         return (long)ret_conv;
1313 }
1314
1315 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_justice_transaction(uint32_t this_arg, int8_tArray justice_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1316         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1317         LDKTransaction justice_tx_ref;
1318         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1319         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1320         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1321         justice_tx_ref.data_is_owned = true;
1322         unsigned char per_commitment_key_arr[32];
1323         CHECK(*((uint32_t*)per_commitment_key) == 32);
1324         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1325         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1326         LDKHTLCOutputInCommitment htlc_conv;
1327         htlc_conv.inner = (void*)(htlc & (~1));
1328         htlc_conv.is_owned = false;
1329         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1330         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1331         return (long)ret_conv;
1332 }
1333
1334 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
1335         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1336         LDKTransaction htlc_tx_ref;
1337         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1338         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1339         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1340         htlc_tx_ref.data_is_owned = true;
1341         LDKPublicKey per_commitment_point_ref;
1342         CHECK(*((uint32_t*)per_commitment_point) == 33);
1343         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1344         LDKHTLCOutputInCommitment htlc_conv;
1345         htlc_conv.inner = (void*)(htlc & (~1));
1346         htlc_conv.is_owned = false;
1347         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1348         *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);
1349         return (long)ret_conv;
1350 }
1351
1352 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1353         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1354         LDKTransaction closing_tx_ref;
1355         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1356         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1357         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1358         closing_tx_ref.data_is_owned = true;
1359         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1360         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1361         return (long)ret_conv;
1362 }
1363
1364 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1365         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1366         LDKUnsignedChannelAnnouncement msg_conv;
1367         msg_conv.inner = (void*)(msg & (~1));
1368         msg_conv.is_owned = false;
1369         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1370         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1371         return (long)ret_conv;
1372 }
1373
1374 void  __attribute__((visibility("default"))) TS_ChannelKeys_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1375         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1376         LDKChannelTransactionParameters channel_parameters_conv;
1377         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1378         channel_parameters_conv.is_owned = false;
1379         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1380 }
1381
1382 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_write(uint32_t this_arg) {
1383         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1384         LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1385         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1386         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
1387         CVec_u8Z_free(arg_var);
1388         return arg_arr;
1389 }
1390
1391 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
1392         if (this_arg->set_pubkeys != NULL)
1393                 this_arg->set_pubkeys(this_arg);
1394         return this_arg->pubkeys;
1395 }
1396 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_get_pubkeys(uint32_t this_arg) {
1397         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1398         LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
1399         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1400         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1401         long ret_ref = (long)ret_var.inner;
1402         if (ret_var.is_owned) {
1403                 ret_ref |= 1;
1404         }
1405         return ret_ref;
1406 }
1407
1408 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1409         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1410         LDKThirtyTwoBytes a_ref;
1411         CHECK(*((uint32_t*)a) == 32);
1412         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1413         ret->a = a_ref;
1414         LDKChannelMonitor b_conv;
1415         b_conv.inner = (void*)(b & (~1));
1416         b_conv.is_owned = (b & 1) || (b == 0);
1417         // Warning: we may need a move here but can't clone!
1418         ret->b = b_conv;
1419         return (long)ret;
1420 }
1421 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1422         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1423         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1424         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1425         return a_arr;
1426 }
1427 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1428         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1429         LDKChannelMonitor b_var = tuple->b;
1430         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1431         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1432         long b_ref = (long)b_var.inner & ~1;
1433         return b_ref;
1434 }
1435 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
1436         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1437 }
1438 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
1439         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1440         CHECK(val->result_ok);
1441         long res_ref = (long)&(*val->contents.result);
1442         return res_ref;
1443 }
1444 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
1445         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1446         CHECK(!val->result_ok);
1447         LDKDecodeError err_var = (*val->contents.err);
1448         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1449         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1450         long err_ref = (long)err_var.inner & ~1;
1451         return err_ref;
1452 }
1453 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1454         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1455 }
1456 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1457         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1458         CHECK(val->result_ok);
1459         long res_ref = (long)&(*val->contents.result);
1460         return res_ref;
1461 }
1462 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1463         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1464         CHECK(!val->result_ok);
1465         LDKDecodeError err_var = (*val->contents.err);
1466         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1467         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1468         long err_ref = (long)err_var.inner & ~1;
1469         return err_ref;
1470 }
1471 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_result_ok(uint32_t arg) {
1472         return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
1473 }
1474 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_ok(uint32_t arg) {
1475         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1476         CHECK(val->result_ok);
1477         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1478         *ret = (*val->contents.result);
1479         return (long)ret;
1480 }
1481 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_err(uint32_t arg) {
1482         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1483         CHECK(!val->result_ok);
1484         LDKDecodeError err_var = (*val->contents.err);
1485         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1486         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1487         long err_ref = (long)err_var.inner & ~1;
1488         return err_ref;
1489 }
1490 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_result_ok(uint32_t arg) {
1491         return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
1492 }
1493 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_ok(uint32_t arg) {
1494         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1495         CHECK(val->result_ok);
1496         LDKInMemoryChannelKeys res_var = (*val->contents.result);
1497         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1498         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1499         long res_ref = (long)res_var.inner & ~1;
1500         return res_ref;
1501 }
1502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_err(uint32_t arg) {
1503         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1504         CHECK(!val->result_ok);
1505         LDKDecodeError err_var = (*val->contents.err);
1506         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1507         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1508         long err_ref = (long)err_var.inner & ~1;
1509         return err_ref;
1510 }
1511 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
1512         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1513 }
1514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
1515         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1516         CHECK(val->result_ok);
1517         long res_ref = (long)&(*val->contents.result);
1518         return (long)res_ref;
1519 }
1520 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
1521         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1522         CHECK(!val->result_ok);
1523         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1524         return err_conv;
1525 }
1526 static inline LDKCResult_TxOutAccessErrorZ CResult_TxOutAccessErrorZ_clone(const LDKCResult_TxOutAccessErrorZ *orig) {
1527         LDKCResult_TxOutAccessErrorZ res = { .result_ok = orig->result_ok };
1528         if (orig->result_ok) {
1529                 LDKTxOut* contents = MALLOC(sizeof(LDKTxOut), "LDKTxOut result OK clone");
1530                 *contents = TxOut_clone(orig->contents.result);
1531                 res.contents.result = contents;
1532         } else {
1533                 LDKAccessError* contents = MALLOC(sizeof(LDKAccessError), "LDKAccessError result Err clone");
1534                 *contents = AccessError_clone(orig->contents.err);
1535                 res.contents.err = contents;
1536         }
1537         return res;
1538 }
1539 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
1540         LDKAPIError *obj = (LDKAPIError*)ptr;
1541         switch(obj->tag) {
1542                 case LDKAPIError_APIMisuseError: {
1543                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
1544                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1545                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1546                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
1547                 }
1548                 case LDKAPIError_FeeRateTooHigh: {
1549                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
1550                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1551                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1552                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
1553                 }
1554                 case LDKAPIError_RouteError: {
1555                         LDKStr err_str = obj->route_error.err;
1556                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1557                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
1558                 }
1559                 case LDKAPIError_ChannelUnavailable: {
1560                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
1561                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1562                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1563                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
1564                 }
1565                 case LDKAPIError_MonitorUpdateFailed: {
1566                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
1567                 }
1568                 default: abort();
1569         }
1570 }
1571 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
1572         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
1573 }
1574 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
1575         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1576         CHECK(val->result_ok);
1577         return *val->contents.result;
1578 }
1579 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
1580         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1581         CHECK(!val->result_ok);
1582         long err_ref = (long)&(*val->contents.err);
1583         return err_ref;
1584 }
1585 static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
1586         LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
1587         if (orig->result_ok) {
1588                 res.contents.result = NULL;
1589         } else {
1590                 LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
1591                 *contents = APIError_clone(orig->contents.err);
1592                 res.contents.err = contents;
1593         }
1594         return res;
1595 }
1596 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
1597         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1598         ret->datalen = *((uint32_t*)elems);
1599         if (ret->datalen == 0) {
1600                 ret->data = NULL;
1601         } else {
1602                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1603                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1604                 for (size_t i = 0; i < ret->datalen; i++) {
1605                         uint32_t arr_elem = java_elems[i];
1606                         LDKChannelDetails arr_elem_conv;
1607                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1608                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1609                         if (arr_elem_conv.inner != NULL)
1610                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1611                         ret->data[i] = arr_elem_conv;
1612                 }
1613         }
1614         return (long)ret;
1615 }
1616 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1617         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1618         for (size_t i = 0; i < ret.datalen; i++) {
1619                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1620         }
1621         return ret;
1622 }
1623 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
1624         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
1625 }
1626 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
1627         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1628         CHECK(val->result_ok);
1629         return *val->contents.result;
1630 }
1631 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
1632         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1633         CHECK(!val->result_ok);
1634         LDKPaymentSendFailure err_var = (*val->contents.err);
1635         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1636         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1637         long err_ref = (long)err_var.inner & ~1;
1638         return err_ref;
1639 }
1640 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1641         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1642         switch(obj->tag) {
1643                 case LDKNetAddress_IPv4: {
1644                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1645                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1646                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1647                 }
1648                 case LDKNetAddress_IPv6: {
1649                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1650                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1651                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1652                 }
1653                 case LDKNetAddress_OnionV2: {
1654                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1655                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1656                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1657                 }
1658                 case LDKNetAddress_OnionV3: {
1659                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1660                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1661                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1662                 }
1663                 default: abort();
1664         }
1665 }
1666 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1667         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1668         ret->datalen = *((uint32_t*)elems);
1669         if (ret->datalen == 0) {
1670                 ret->data = NULL;
1671         } else {
1672                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1673                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1674                 for (size_t i = 0; i < ret->datalen; i++) {
1675                         uint32_t arr_elem = java_elems[i];
1676                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
1677                         FREE((void*)arr_elem);
1678                         ret->data[i] = arr_elem_conv;
1679                 }
1680         }
1681         return (long)ret;
1682 }
1683 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1684         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1685         for (size_t i = 0; i < ret.datalen; i++) {
1686                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1687         }
1688         return ret;
1689 }
1690 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
1691         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
1692         ret->datalen = *((uint32_t*)elems);
1693         if (ret->datalen == 0) {
1694                 ret->data = NULL;
1695         } else {
1696                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
1697                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1698                 for (size_t i = 0; i < ret->datalen; i++) {
1699                         uint32_t arr_elem = java_elems[i];
1700                         LDKChannelMonitor arr_elem_conv;
1701                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1702                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1703                         // Warning: we may need a move here but can't clone!
1704                         ret->data[i] = arr_elem_conv;
1705                 }
1706         }
1707         return (long)ret;
1708 }
1709 typedef struct LDKWatch_JCalls {
1710         atomic_size_t refcnt;
1711         uint32_t watch_channel_meth;
1712         uint32_t update_channel_meth;
1713         uint32_t release_pending_monitor_events_meth;
1714 } LDKWatch_JCalls;
1715 static void LDKWatch_JCalls_free(void* this_arg) {
1716         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1717         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1718                 js_free(j_calls->watch_channel_meth);
1719                 js_free(j_calls->update_channel_meth);
1720                 js_free(j_calls->release_pending_monitor_events_meth);
1721                 FREE(j_calls);
1722         }
1723 }
1724 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
1725         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1726         LDKOutPoint funding_txo_var = funding_txo;
1727         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1728         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1729         long funding_txo_ref = (long)funding_txo_var.inner;
1730         if (funding_txo_var.is_owned) {
1731                 funding_txo_ref |= 1;
1732         }
1733         LDKChannelMonitor monitor_var = monitor;
1734         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1735         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1736         long monitor_ref = (long)monitor_var.inner;
1737         if (monitor_var.is_owned) {
1738                 monitor_ref |= 1;
1739         }
1740         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
1741         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
1742         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
1743         return ret_conv;
1744 }
1745 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
1746         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1747         LDKOutPoint funding_txo_var = funding_txo;
1748         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1749         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1750         long funding_txo_ref = (long)funding_txo_var.inner;
1751         if (funding_txo_var.is_owned) {
1752                 funding_txo_ref |= 1;
1753         }
1754         LDKChannelMonitorUpdate update_var = update;
1755         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1756         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1757         long update_ref = (long)update_var.inner;
1758         if (update_var.is_owned) {
1759                 update_ref |= 1;
1760         }
1761         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
1762         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
1763         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
1764         return ret_conv;
1765 }
1766 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
1767         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1768         uint32_tArray arg = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
1769         LDKCVec_MonitorEventZ arg_constr;
1770         arg_constr.datalen = *((uint32_t*)arg);
1771         if (arg_constr.datalen > 0)
1772                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
1773         else
1774                 arg_constr.data = NULL;
1775         uint32_t* arg_vals = (uint32_t*)(arg + 4);
1776         for (size_t o = 0; o < arg_constr.datalen; o++) {
1777                 uint32_t arr_conv_14 = arg_vals[o];
1778                 LDKMonitorEvent arr_conv_14_conv;
1779                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
1780                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
1781                 if (arr_conv_14_conv.inner != NULL)
1782                         arr_conv_14_conv = MonitorEvent_clone(&arr_conv_14_conv);
1783                 arg_constr.data[o] = arr_conv_14_conv;
1784         }
1785         return arg_constr;
1786 }
1787 static void* LDKWatch_JCalls_clone(const void* this_arg) {
1788         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1789         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1790         return (void*) this_arg;
1791 }
1792 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
1793         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
1794         atomic_init(&calls->refcnt, 1);
1795         //TODO: Assign calls->o from o
1796
1797         LDKWatch ret = {
1798                 .this_arg = (void*) calls,
1799                 .watch_channel = watch_channel_jcall,
1800                 .update_channel = update_channel_jcall,
1801                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
1802                 .free = LDKWatch_JCalls_free,
1803         };
1804         return ret;
1805 }
1806 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
1807         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
1808         *res_ptr = LDKWatch_init(o);
1809         return (long)res_ptr;
1810 }
1811 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
1812         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1813         LDKOutPoint funding_txo_conv;
1814         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1815         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1816         if (funding_txo_conv.inner != NULL)
1817                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1818         LDKChannelMonitor monitor_conv;
1819         monitor_conv.inner = (void*)(monitor & (~1));
1820         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
1821         // Warning: we may need a move here but can't clone!
1822         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1823         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
1824         return (long)ret_conv;
1825 }
1826
1827 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
1828         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1829         LDKOutPoint funding_txo_conv;
1830         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1831         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1832         if (funding_txo_conv.inner != NULL)
1833                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1834         LDKChannelMonitorUpdate update_conv;
1835         update_conv.inner = (void*)(update & (~1));
1836         update_conv.is_owned = (update & 1) || (update == 0);
1837         if (update_conv.inner != NULL)
1838                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
1839         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1840         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
1841         return (long)ret_conv;
1842 }
1843
1844 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
1845         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1846         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
1847         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1848         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
1849         for (size_t o = 0; o < ret_var.datalen; o++) {
1850                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
1851                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1852                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1853                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
1854                 if (arr_conv_14_var.is_owned) {
1855                         arr_conv_14_ref |= 1;
1856                 }
1857                 ret_arr_ptr[o] = arr_conv_14_ref;
1858         }
1859         FREE(ret_var.data);
1860         return ret_arr;
1861 }
1862
1863 typedef struct LDKBroadcasterInterface_JCalls {
1864         atomic_size_t refcnt;
1865         uint32_t broadcast_transaction_meth;
1866 } LDKBroadcasterInterface_JCalls;
1867 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
1868         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1869         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1870                 js_free(j_calls->broadcast_transaction_meth);
1871                 FREE(j_calls);
1872         }
1873 }
1874 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
1875         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1876         LDKTransaction tx_var = tx;
1877         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1878         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
1879         Transaction_free(tx_var);
1880         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
1881 }
1882 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
1883         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1884         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1885         return (void*) this_arg;
1886 }
1887 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
1888         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
1889         atomic_init(&calls->refcnt, 1);
1890         //TODO: Assign calls->o from o
1891
1892         LDKBroadcasterInterface ret = {
1893                 .this_arg = (void*) calls,
1894                 .broadcast_transaction = broadcast_transaction_jcall,
1895                 .free = LDKBroadcasterInterface_JCalls_free,
1896         };
1897         return ret;
1898 }
1899 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
1900         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
1901         *res_ptr = LDKBroadcasterInterface_init(o);
1902         return (long)res_ptr;
1903 }
1904 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
1905         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
1906         LDKTransaction tx_ref;
1907         tx_ref.datalen = *((uint32_t*)tx);
1908         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
1909         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
1910         tx_ref.data_is_owned = true;
1911         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
1912 }
1913
1914 typedef struct LDKKeysInterface_JCalls {
1915         atomic_size_t refcnt;
1916         uint32_t get_node_secret_meth;
1917         uint32_t get_destination_script_meth;
1918         uint32_t get_shutdown_pubkey_meth;
1919         uint32_t get_channel_keys_meth;
1920         uint32_t get_secure_random_bytes_meth;
1921         uint32_t read_chan_signer_meth;
1922 } LDKKeysInterface_JCalls;
1923 static void LDKKeysInterface_JCalls_free(void* this_arg) {
1924         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1925         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1926                 js_free(j_calls->get_node_secret_meth);
1927                 js_free(j_calls->get_destination_script_meth);
1928                 js_free(j_calls->get_shutdown_pubkey_meth);
1929                 js_free(j_calls->get_channel_keys_meth);
1930                 js_free(j_calls->get_secure_random_bytes_meth);
1931                 js_free(j_calls->read_chan_signer_meth);
1932                 FREE(j_calls);
1933         }
1934 }
1935 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
1936         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1937         int8_tArray arg = js_invoke_function_0(j_calls->get_node_secret_meth);
1938         LDKSecretKey arg_ref;
1939         CHECK(*((uint32_t*)arg) == 32);
1940         memcpy(arg_ref.bytes, (uint8_t*)(arg + 4), 32);
1941         return arg_ref;
1942 }
1943 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
1944         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1945         int8_tArray arg = js_invoke_function_0(j_calls->get_destination_script_meth);
1946         LDKCVec_u8Z arg_ref;
1947         arg_ref.datalen = *((uint32_t*)arg);
1948         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1949         memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1950         return arg_ref;
1951 }
1952 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
1953         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1954         int8_tArray arg = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
1955         LDKPublicKey arg_ref;
1956         CHECK(*((uint32_t*)arg) == 33);
1957         memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
1958         return arg_ref;
1959 }
1960 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
1961         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1962         LDKChannelKeys* ret = (LDKChannelKeys*)js_invoke_function_2(j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
1963         LDKChannelKeys ret_conv = *(LDKChannelKeys*)ret;
1964         ret_conv = ChannelKeys_clone(ret);
1965         return ret_conv;
1966 }
1967 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
1968         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1969         int8_tArray arg = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
1970         LDKThirtyTwoBytes arg_ref;
1971         CHECK(*((uint32_t*)arg) == 32);
1972         memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
1973         return arg_ref;
1974 }
1975 LDKCResult_ChanKeySignerDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
1976         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1977         LDKu8slice reader_var = reader;
1978         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1979         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
1980         LDKCResult_ChanKeySignerDecodeErrorZ* ret = (LDKCResult_ChanKeySignerDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
1981         LDKCResult_ChanKeySignerDecodeErrorZ ret_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)ret;
1982         // Warning: we may need a move here but can't do a full clone!
1983         return ret_conv;
1984 }
1985 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
1986         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1987         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1988         return (void*) this_arg;
1989 }
1990 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
1991         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
1992         atomic_init(&calls->refcnt, 1);
1993         //TODO: Assign calls->o from o
1994
1995         LDKKeysInterface ret = {
1996                 .this_arg = (void*) calls,
1997                 .get_node_secret = get_node_secret_jcall,
1998                 .get_destination_script = get_destination_script_jcall,
1999                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
2000                 .get_channel_keys = get_channel_keys_jcall,
2001                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
2002                 .read_chan_signer = read_chan_signer_jcall,
2003                 .free = LDKKeysInterface_JCalls_free,
2004         };
2005         return ret;
2006 }
2007 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2008         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2009         *res_ptr = LDKKeysInterface_init(o);
2010         return (long)res_ptr;
2011 }
2012 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2013         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2014         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2015         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2016         return arg_arr;
2017 }
2018
2019 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2020         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2021         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2022         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2023         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
2024         CVec_u8Z_free(arg_var);
2025         return arg_arr;
2026 }
2027
2028 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
2029         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2030         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2031         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
2032         return arg_arr;
2033 }
2034
2035 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_keys(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2036         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2037         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
2038         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2039         return (long)ret;
2040 }
2041
2042 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2043         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2044         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2045         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2046         return arg_arr;
2047 }
2048
2049 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2050         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2051         LDKu8slice reader_ref;
2052         reader_ref.datalen = *((uint32_t*)reader);
2053         reader_ref.data = (int8_t*)(reader + 4);
2054         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
2055         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2056         return (long)ret_conv;
2057 }
2058
2059 typedef struct LDKFeeEstimator_JCalls {
2060         atomic_size_t refcnt;
2061         uint32_t get_est_sat_per_1000_weight_meth;
2062 } LDKFeeEstimator_JCalls;
2063 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2064         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2065         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2066                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2067                 FREE(j_calls);
2068         }
2069 }
2070 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2071         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2072         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2073         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2074 }
2075 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2076         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2077         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2078         return (void*) this_arg;
2079 }
2080 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2081         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2082         atomic_init(&calls->refcnt, 1);
2083         //TODO: Assign calls->o from o
2084
2085         LDKFeeEstimator ret = {
2086                 .this_arg = (void*) calls,
2087                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2088                 .free = LDKFeeEstimator_JCalls_free,
2089         };
2090         return ret;
2091 }
2092 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2093         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2094         *res_ptr = LDKFeeEstimator_init(o);
2095         return (long)res_ptr;
2096 }
2097 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2098         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2099         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2100         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2101         return ret_val;
2102 }
2103
2104 typedef struct LDKLogger_JCalls {
2105         atomic_size_t refcnt;
2106         uint32_t log_meth;
2107 } LDKLogger_JCalls;
2108 static void LDKLogger_JCalls_free(void* this_arg) {
2109         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2110         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2111                 js_free(j_calls->log_meth);
2112                 FREE(j_calls);
2113         }
2114 }
2115 void log_jcall(const void* this_arg, const char* record) {
2116         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2117         const char* record_str = record;
2118         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2119         js_invoke_function_1(j_calls->log_meth, record_conv);
2120 }
2121 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2122         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2123         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2124         return (void*) this_arg;
2125 }
2126 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2127         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2128         atomic_init(&calls->refcnt, 1);
2129         //TODO: Assign calls->o from o
2130
2131         LDKLogger ret = {
2132                 .this_arg = (void*) calls,
2133                 .log = log_jcall,
2134                 .free = LDKLogger_JCalls_free,
2135         };
2136         return ret;
2137 }
2138 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2139         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2140         *res_ptr = LDKLogger_init(o);
2141         return (long)res_ptr;
2142 }
2143 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2144         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2145         LDKThirtyTwoBytes a_ref;
2146         CHECK(*((uint32_t*)a) == 32);
2147         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2148         ret->a = a_ref;
2149         LDKChannelManager b_conv;
2150         b_conv.inner = (void*)(b & (~1));
2151         b_conv.is_owned = (b & 1) || (b == 0);
2152         // Warning: we may need a move here but can't clone!
2153         ret->b = b_conv;
2154         return (long)ret;
2155 }
2156 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2157         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
2158         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2159         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2160         return a_arr;
2161 }
2162 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2163         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
2164         LDKChannelManager b_var = tuple->b;
2165         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2166         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2167         long b_ref = (long)b_var.inner & ~1;
2168         return b_ref;
2169 }
2170 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2171         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2172 }
2173 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2174         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
2175         CHECK(val->result_ok);
2176         long res_ref = (long)&(*val->contents.result);
2177         return res_ref;
2178 }
2179 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2180         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
2181         CHECK(!val->result_ok);
2182         LDKDecodeError err_var = (*val->contents.err);
2183         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2184         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2185         long err_ref = (long)err_var.inner & ~1;
2186         return err_ref;
2187 }
2188 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
2189         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
2190 }
2191 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
2192         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
2193         CHECK(val->result_ok);
2194         long res_ref = (long)&(*val->contents.result);
2195         return res_ref;
2196 }
2197 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
2198         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
2199         CHECK(!val->result_ok);
2200         return *val->contents.err;
2201 }
2202 static inline LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const LDKCResult_NetAddressu8Z *orig) {
2203         LDKCResult_NetAddressu8Z res = { .result_ok = orig->result_ok };
2204         if (orig->result_ok) {
2205                 LDKNetAddress* contents = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress result OK clone");
2206                 *contents = NetAddress_clone(orig->contents.result);
2207                 res.contents.result = contents;
2208         } else {
2209                 int8_t* contents = MALLOC(sizeof(int8_t), "int8_t result Err clone");
2210                 *contents = *orig->contents.err;
2211                 res.contents.err = contents;
2212         }
2213         return res;
2214 }
2215 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
2216         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
2217 }
2218 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
2219         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
2220         CHECK(val->result_ok);
2221         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
2222         *res_conv = (*val->contents.result);
2223         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
2224         return (long)res_conv;
2225 }
2226 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
2227         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
2228         CHECK(!val->result_ok);
2229         LDKDecodeError err_var = (*val->contents.err);
2230         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2231         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2232         long err_ref = (long)err_var.inner & ~1;
2233         return err_ref;
2234 }
2235 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
2236         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2237         ret->datalen = *((uint32_t*)elems);
2238         if (ret->datalen == 0) {
2239                 ret->data = NULL;
2240         } else {
2241                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2242                 int64_t *java_elems = (int64_t*)(elems + 4);
2243                 for (size_t i = 0; i < ret->datalen; i++) {
2244                         ret->data[i] = java_elems[i];
2245                 }
2246         }
2247         return (long)ret;
2248 }
2249 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2250         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2251         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2252         return ret;
2253 }
2254 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
2255         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
2256         ret->datalen = *((uint32_t*)elems);
2257         if (ret->datalen == 0) {
2258                 ret->data = NULL;
2259         } else {
2260                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
2261                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2262                 for (size_t i = 0; i < ret->datalen; i++) {
2263                         uint32_t arr_elem = java_elems[i];
2264                         LDKUpdateAddHTLC arr_elem_conv;
2265                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2266                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2267                         if (arr_elem_conv.inner != NULL)
2268                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
2269                         ret->data[i] = arr_elem_conv;
2270                 }
2271         }
2272         return (long)ret;
2273 }
2274 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
2275         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
2276         for (size_t i = 0; i < ret.datalen; i++) {
2277                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
2278         }
2279         return ret;
2280 }
2281 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
2282         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
2283         ret->datalen = *((uint32_t*)elems);
2284         if (ret->datalen == 0) {
2285                 ret->data = NULL;
2286         } else {
2287                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
2288                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2289                 for (size_t i = 0; i < ret->datalen; i++) {
2290                         uint32_t arr_elem = java_elems[i];
2291                         LDKUpdateFulfillHTLC arr_elem_conv;
2292                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2293                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2294                         if (arr_elem_conv.inner != NULL)
2295                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
2296                         ret->data[i] = arr_elem_conv;
2297                 }
2298         }
2299         return (long)ret;
2300 }
2301 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
2302         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
2303         for (size_t i = 0; i < ret.datalen; i++) {
2304                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
2305         }
2306         return ret;
2307 }
2308 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
2309         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
2310         ret->datalen = *((uint32_t*)elems);
2311         if (ret->datalen == 0) {
2312                 ret->data = NULL;
2313         } else {
2314                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
2315                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2316                 for (size_t i = 0; i < ret->datalen; i++) {
2317                         uint32_t arr_elem = java_elems[i];
2318                         LDKUpdateFailHTLC arr_elem_conv;
2319                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2320                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2321                         if (arr_elem_conv.inner != NULL)
2322                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
2323                         ret->data[i] = arr_elem_conv;
2324                 }
2325         }
2326         return (long)ret;
2327 }
2328 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
2329         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
2330         for (size_t i = 0; i < ret.datalen; i++) {
2331                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
2332         }
2333         return ret;
2334 }
2335 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
2336         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
2337         ret->datalen = *((uint32_t*)elems);
2338         if (ret->datalen == 0) {
2339                 ret->data = NULL;
2340         } else {
2341                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
2342                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2343                 for (size_t i = 0; i < ret->datalen; i++) {
2344                         uint32_t arr_elem = java_elems[i];
2345                         LDKUpdateFailMalformedHTLC arr_elem_conv;
2346                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2347                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2348                         if (arr_elem_conv.inner != NULL)
2349                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
2350                         ret->data[i] = arr_elem_conv;
2351                 }
2352         }
2353         return (long)ret;
2354 }
2355 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
2356         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
2357         for (size_t i = 0; i < ret.datalen; i++) {
2358                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
2359         }
2360         return ret;
2361 }
2362 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
2363         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
2364 }
2365 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
2366         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2367         CHECK(val->result_ok);
2368         return *val->contents.result;
2369 }
2370 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
2371         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2372         CHECK(!val->result_ok);
2373         LDKLightningError err_var = (*val->contents.err);
2374         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2375         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2376         long err_ref = (long)err_var.inner & ~1;
2377         return err_ref;
2378 }
2379 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
2380         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2381         LDKChannelAnnouncement a_conv;
2382         a_conv.inner = (void*)(a & (~1));
2383         a_conv.is_owned = (a & 1) || (a == 0);
2384         if (a_conv.inner != NULL)
2385                 a_conv = ChannelAnnouncement_clone(&a_conv);
2386         ret->a = a_conv;
2387         LDKChannelUpdate b_conv;
2388         b_conv.inner = (void*)(b & (~1));
2389         b_conv.is_owned = (b & 1) || (b == 0);
2390         if (b_conv.inner != NULL)
2391                 b_conv = ChannelUpdate_clone(&b_conv);
2392         ret->b = b_conv;
2393         LDKChannelUpdate c_conv;
2394         c_conv.inner = (void*)(c & (~1));
2395         c_conv.is_owned = (c & 1) || (c == 0);
2396         if (c_conv.inner != NULL)
2397                 c_conv = ChannelUpdate_clone(&c_conv);
2398         ret->c = c_conv;
2399         return (long)ret;
2400 }
2401 static inline LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *orig) {
2402         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret = {
2403                 .a = ChannelAnnouncement_clone(&orig->a),
2404                 .b = ChannelUpdate_clone(&orig->b),
2405                 .c = ChannelUpdate_clone(&orig->c),
2406         };
2407         return ret;
2408 }
2409 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
2410         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2411         LDKChannelAnnouncement a_var = tuple->a;
2412         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2413         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2414         long a_ref = (long)a_var.inner & ~1;
2415         return a_ref;
2416 }
2417 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
2418         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2419         LDKChannelUpdate b_var = tuple->b;
2420         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2421         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2422         long b_ref = (long)b_var.inner & ~1;
2423         return b_ref;
2424 }
2425 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
2426         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2427         LDKChannelUpdate c_var = tuple->c;
2428         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2429         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2430         long c_ref = (long)c_var.inner & ~1;
2431         return c_ref;
2432 }
2433 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
2434         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2435         ret->datalen = *((uint32_t*)elems);
2436         if (ret->datalen == 0) {
2437                 ret->data = NULL;
2438         } else {
2439                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2440                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2441                 for (size_t i = 0; i < ret->datalen; i++) {
2442                         uint32_t arr_elem = java_elems[i];
2443                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_elem;
2444                         FREE((void*)arr_elem);
2445                         ret->data[i] = arr_elem_conv;
2446                 }
2447         }
2448         return (long)ret;
2449 }
2450 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2451         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2452         for (size_t i = 0; i < ret.datalen; i++) {
2453                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2454         }
2455         return ret;
2456 }
2457 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
2458         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2459         ret->datalen = *((uint32_t*)elems);
2460         if (ret->datalen == 0) {
2461                 ret->data = NULL;
2462         } else {
2463                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2464                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2465                 for (size_t i = 0; i < ret->datalen; i++) {
2466                         uint32_t arr_elem = java_elems[i];
2467                         LDKNodeAnnouncement arr_elem_conv;
2468                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2469                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2470                         if (arr_elem_conv.inner != NULL)
2471                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2472                         ret->data[i] = arr_elem_conv;
2473                 }
2474         }
2475         return (long)ret;
2476 }
2477 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2478         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2479         for (size_t i = 0; i < ret.datalen; i++) {
2480                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2481         }
2482         return ret;
2483 }
2484 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
2485         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2486 }
2487 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
2488         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2489         CHECK(val->result_ok);
2490         return *val->contents.result;
2491 }
2492 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
2493         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2494         CHECK(!val->result_ok);
2495         LDKLightningError err_var = (*val->contents.err);
2496         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2497         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2498         long err_ref = (long)err_var.inner & ~1;
2499         return err_ref;
2500 }
2501 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
2502         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
2503 }
2504 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
2505         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2506         CHECK(val->result_ok);
2507         LDKChannelReestablish res_var = (*val->contents.result);
2508         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2509         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2510         long res_ref = (long)res_var.inner & ~1;
2511         return res_ref;
2512 }
2513 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
2514         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2515         CHECK(!val->result_ok);
2516         LDKDecodeError err_var = (*val->contents.err);
2517         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2518         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2519         long err_ref = (long)err_var.inner & ~1;
2520         return err_ref;
2521 }
2522 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
2523         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
2524 }
2525 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
2526         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2527         CHECK(val->result_ok);
2528         LDKInit res_var = (*val->contents.result);
2529         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2530         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2531         long res_ref = (long)res_var.inner & ~1;
2532         return res_ref;
2533 }
2534 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
2535         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2536         CHECK(!val->result_ok);
2537         LDKDecodeError err_var = (*val->contents.err);
2538         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2539         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2540         long err_ref = (long)err_var.inner & ~1;
2541         return err_ref;
2542 }
2543 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
2544         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
2545 }
2546 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
2547         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2548         CHECK(val->result_ok);
2549         LDKPing res_var = (*val->contents.result);
2550         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2551         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2552         long res_ref = (long)res_var.inner & ~1;
2553         return res_ref;
2554 }
2555 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
2556         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2557         CHECK(!val->result_ok);
2558         LDKDecodeError err_var = (*val->contents.err);
2559         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2560         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2561         long err_ref = (long)err_var.inner & ~1;
2562         return err_ref;
2563 }
2564 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
2565         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
2566 }
2567 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
2568         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2569         CHECK(val->result_ok);
2570         LDKPong res_var = (*val->contents.result);
2571         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2572         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2573         long res_ref = (long)res_var.inner & ~1;
2574         return res_ref;
2575 }
2576 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
2577         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2578         CHECK(!val->result_ok);
2579         LDKDecodeError err_var = (*val->contents.err);
2580         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2581         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2582         long err_ref = (long)err_var.inner & ~1;
2583         return err_ref;
2584 }
2585 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2586         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2587 }
2588 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2589         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2590         CHECK(val->result_ok);
2591         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
2592         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2593         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2594         long res_ref = (long)res_var.inner & ~1;
2595         return res_ref;
2596 }
2597 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2598         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2599         CHECK(!val->result_ok);
2600         LDKDecodeError err_var = (*val->contents.err);
2601         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2602         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2603         long err_ref = (long)err_var.inner & ~1;
2604         return err_ref;
2605 }
2606 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
2607         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
2608 }
2609 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
2610         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2611         CHECK(val->result_ok);
2612         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
2613         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2614         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2615         long res_ref = (long)res_var.inner & ~1;
2616         return res_ref;
2617 }
2618 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
2619         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2620         CHECK(!val->result_ok);
2621         LDKDecodeError err_var = (*val->contents.err);
2622         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2623         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2624         long err_ref = (long)err_var.inner & ~1;
2625         return err_ref;
2626 }
2627 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
2628         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
2629 }
2630 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
2631         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2632         CHECK(val->result_ok);
2633         LDKErrorMessage res_var = (*val->contents.result);
2634         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2635         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2636         long res_ref = (long)res_var.inner & ~1;
2637         return res_ref;
2638 }
2639 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
2640         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2641         CHECK(!val->result_ok);
2642         LDKDecodeError err_var = (*val->contents.err);
2643         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2644         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2645         long err_ref = (long)err_var.inner & ~1;
2646         return err_ref;
2647 }
2648 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2649         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
2650 }
2651 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2652         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2653         CHECK(val->result_ok);
2654         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
2655         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2656         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2657         long res_ref = (long)res_var.inner & ~1;
2658         return res_ref;
2659 }
2660 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2661         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2662         CHECK(!val->result_ok);
2663         LDKDecodeError err_var = (*val->contents.err);
2664         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2665         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2666         long err_ref = (long)err_var.inner & ~1;
2667         return err_ref;
2668 }
2669 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
2670         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
2671 }
2672 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
2673         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2674         CHECK(val->result_ok);
2675         LDKQueryShortChannelIds res_var = (*val->contents.result);
2676         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2677         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2678         long res_ref = (long)res_var.inner & ~1;
2679         return res_ref;
2680 }
2681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
2682         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2683         CHECK(!val->result_ok);
2684         LDKDecodeError err_var = (*val->contents.err);
2685         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2686         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2687         long err_ref = (long)err_var.inner & ~1;
2688         return err_ref;
2689 }
2690 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
2691         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
2692 }
2693 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
2694         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2695         CHECK(val->result_ok);
2696         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
2697         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2698         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2699         long res_ref = (long)res_var.inner & ~1;
2700         return res_ref;
2701 }
2702 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
2703         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2704         CHECK(!val->result_ok);
2705         LDKDecodeError err_var = (*val->contents.err);
2706         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2707         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2708         long err_ref = (long)err_var.inner & ~1;
2709         return err_ref;
2710 }
2711 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2712         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
2713 }
2714 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2715         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2716         CHECK(val->result_ok);
2717         LDKQueryChannelRange res_var = (*val->contents.result);
2718         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2719         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2720         long res_ref = (long)res_var.inner & ~1;
2721         return res_ref;
2722 }
2723 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2724         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2725         CHECK(!val->result_ok);
2726         LDKDecodeError err_var = (*val->contents.err);
2727         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2728         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2729         long err_ref = (long)err_var.inner & ~1;
2730         return err_ref;
2731 }
2732 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2733         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
2734 }
2735 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2736         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2737         CHECK(val->result_ok);
2738         LDKReplyChannelRange res_var = (*val->contents.result);
2739         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2740         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2741         long res_ref = (long)res_var.inner & ~1;
2742         return res_ref;
2743 }
2744 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2745         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2746         CHECK(!val->result_ok);
2747         LDKDecodeError err_var = (*val->contents.err);
2748         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2749         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2750         long err_ref = (long)err_var.inner & ~1;
2751         return err_ref;
2752 }
2753 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
2754         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
2755 }
2756 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
2757         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2758         CHECK(val->result_ok);
2759         LDKGossipTimestampFilter res_var = (*val->contents.result);
2760         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2761         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2762         long res_ref = (long)res_var.inner & ~1;
2763         return res_ref;
2764 }
2765 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
2766         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2767         CHECK(!val->result_ok);
2768         LDKDecodeError err_var = (*val->contents.err);
2769         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2770         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2771         long err_ref = (long)err_var.inner & ~1;
2772         return err_ref;
2773 }
2774 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
2775         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2776 }
2777 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
2778         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2779         CHECK(val->result_ok);
2780         LDKCVec_u8Z res_var = (*val->contents.result);
2781         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2782         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2783         return res_arr;
2784 }
2785 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
2786         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2787         CHECK(!val->result_ok);
2788         LDKPeerHandleError err_var = (*val->contents.err);
2789         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         long err_ref = (long)err_var.inner & ~1;
2792         return err_ref;
2793 }
2794 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
2795         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2796 }
2797 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
2798         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2799         CHECK(val->result_ok);
2800         return *val->contents.result;
2801 }
2802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
2803         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2804         CHECK(!val->result_ok);
2805         LDKPeerHandleError err_var = (*val->contents.err);
2806         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2807         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2808         long err_ref = (long)err_var.inner & ~1;
2809         return err_ref;
2810 }
2811 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
2812         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2813 }
2814 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
2815         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2816         CHECK(val->result_ok);
2817         return *val->contents.result;
2818 }
2819 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
2820         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2821         CHECK(!val->result_ok);
2822         LDKPeerHandleError err_var = (*val->contents.err);
2823         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2824         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2825         long err_ref = (long)err_var.inner & ~1;
2826         return err_ref;
2827 }
2828 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_result_ok(uint32_t arg) {
2829         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
2830 }
2831 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_ok(uint32_t arg) {
2832         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2833         CHECK(val->result_ok);
2834         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2835         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
2836         return res_arr;
2837 }
2838 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_err(uint32_t arg) {
2839         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2840         CHECK(!val->result_ok);
2841         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2842         return err_conv;
2843 }
2844 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_result_ok(uint32_t arg) {
2845         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
2846 }
2847 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_ok(uint32_t arg) {
2848         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2849         CHECK(val->result_ok);
2850         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2851         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
2852         return res_arr;
2853 }
2854 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_err(uint32_t arg) {
2855         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2856         CHECK(!val->result_ok);
2857         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2858         return err_conv;
2859 }
2860 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_result_ok(uint32_t arg) {
2861         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
2862 }
2863 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_ok(uint32_t arg) {
2864         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2865         CHECK(val->result_ok);
2866         LDKTxCreationKeys res_var = (*val->contents.result);
2867         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2868         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2869         long res_ref = (long)res_var.inner & ~1;
2870         return res_ref;
2871 }
2872 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_err(uint32_t arg) {
2873         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2874         CHECK(!val->result_ok);
2875         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2876         return err_conv;
2877 }
2878 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
2879         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
2880 }
2881 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
2882         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2883         CHECK(val->result_ok);
2884         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
2885         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2886         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2887         long res_ref = (long)res_var.inner & ~1;
2888         return res_ref;
2889 }
2890 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
2891         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2892         CHECK(!val->result_ok);
2893         return *val->contents.err;
2894 }
2895 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
2896         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2897         ret->datalen = *((uint32_t*)elems);
2898         if (ret->datalen == 0) {
2899                 ret->data = NULL;
2900         } else {
2901                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2902                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2903                 for (size_t i = 0; i < ret->datalen; i++) {
2904                         uint32_t arr_elem = java_elems[i];
2905                         LDKRouteHop arr_elem_conv;
2906                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2907                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2908                         if (arr_elem_conv.inner != NULL)
2909                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2910                         ret->data[i] = arr_elem_conv;
2911                 }
2912         }
2913         return (long)ret;
2914 }
2915 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2916         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2917         for (size_t i = 0; i < ret.datalen; i++) {
2918                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2919         }
2920         return ret;
2921 }
2922 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2923         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2924         for (size_t i = 0; i < ret.datalen; i++) {
2925                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2926         }
2927         return ret;
2928 }
2929 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
2930         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2931 }
2932 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
2933         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2934         CHECK(val->result_ok);
2935         LDKRoute res_var = (*val->contents.result);
2936         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938         long res_ref = (long)res_var.inner & ~1;
2939         return res_ref;
2940 }
2941 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
2942         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2943         CHECK(!val->result_ok);
2944         LDKDecodeError err_var = (*val->contents.err);
2945         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2946         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2947         long err_ref = (long)err_var.inner & ~1;
2948         return err_ref;
2949 }
2950 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
2951         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2952         ret->datalen = *((uint32_t*)elems);
2953         if (ret->datalen == 0) {
2954                 ret->data = NULL;
2955         } else {
2956                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2957                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2958                 for (size_t i = 0; i < ret->datalen; i++) {
2959                         uint32_t arr_elem = java_elems[i];
2960                         LDKRouteHint arr_elem_conv;
2961                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2962                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2963                         if (arr_elem_conv.inner != NULL)
2964                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2965                         ret->data[i] = arr_elem_conv;
2966                 }
2967         }
2968         return (long)ret;
2969 }
2970 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2971         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2972         for (size_t i = 0; i < ret.datalen; i++) {
2973                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2974         }
2975         return ret;
2976 }
2977 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
2978         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2979 }
2980 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
2981         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2982         CHECK(val->result_ok);
2983         LDKRoute res_var = (*val->contents.result);
2984         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2985         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2986         long res_ref = (long)res_var.inner & ~1;
2987         return res_ref;
2988 }
2989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
2990         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2991         CHECK(!val->result_ok);
2992         LDKLightningError err_var = (*val->contents.err);
2993         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2994         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2995         long err_ref = (long)err_var.inner & ~1;
2996         return err_ref;
2997 }
2998 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
2999         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
3000 }
3001 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
3002         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
3003         CHECK(val->result_ok);
3004         LDKRoutingFees res_var = (*val->contents.result);
3005         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3006         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3007         long res_ref = (long)res_var.inner & ~1;
3008         return res_ref;
3009 }
3010 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
3011         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
3012         CHECK(!val->result_ok);
3013         LDKDecodeError err_var = (*val->contents.err);
3014         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3015         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3016         long err_ref = (long)err_var.inner & ~1;
3017         return err_ref;
3018 }
3019 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
3020         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
3021 }
3022 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
3023         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
3024         CHECK(val->result_ok);
3025         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
3026         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028         long res_ref = (long)res_var.inner & ~1;
3029         return res_ref;
3030 }
3031 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
3032         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
3033         CHECK(!val->result_ok);
3034         LDKDecodeError err_var = (*val->contents.err);
3035         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3036         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3037         long err_ref = (long)err_var.inner & ~1;
3038         return err_ref;
3039 }
3040 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
3041         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3042 }
3043 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3044         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
3045         CHECK(val->result_ok);
3046         LDKNodeInfo res_var = (*val->contents.result);
3047         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3048         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3049         long res_ref = (long)res_var.inner & ~1;
3050         return res_ref;
3051 }
3052 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3053         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
3054         CHECK(!val->result_ok);
3055         LDKDecodeError err_var = (*val->contents.err);
3056         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3057         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3058         long err_ref = (long)err_var.inner & ~1;
3059         return err_ref;
3060 }
3061 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3062         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3063 }
3064 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3065         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
3066         CHECK(val->result_ok);
3067         LDKNetworkGraph res_var = (*val->contents.result);
3068         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3069         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3070         long res_ref = (long)res_var.inner & ~1;
3071         return res_ref;
3072 }
3073 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3074         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
3075         CHECK(!val->result_ok);
3076         LDKDecodeError err_var = (*val->contents.err);
3077         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3078         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3079         long err_ref = (long)err_var.inner & ~1;
3080         return err_ref;
3081 }
3082 typedef struct LDKMessageSendEventsProvider_JCalls {
3083         atomic_size_t refcnt;
3084         uint32_t get_and_clear_pending_msg_events_meth;
3085 } LDKMessageSendEventsProvider_JCalls;
3086 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
3087         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3088         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3089                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
3090                 FREE(j_calls);
3091         }
3092 }
3093 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
3094         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3095         uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
3096         LDKCVec_MessageSendEventZ arg_constr;
3097         arg_constr.datalen = *((uint32_t*)arg);
3098         if (arg_constr.datalen > 0)
3099                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3100         else
3101                 arg_constr.data = NULL;
3102         uint32_t* arg_vals = (uint32_t*)(arg + 4);
3103         for (size_t s = 0; s < arg_constr.datalen; s++) {
3104                 uint32_t arr_conv_18 = arg_vals[s];
3105                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
3106                 FREE((void*)arr_conv_18);
3107                 arg_constr.data[s] = arr_conv_18_conv;
3108         }
3109         return arg_constr;
3110 }
3111 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
3112         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3113         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3114         return (void*) this_arg;
3115 }
3116 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3117         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
3118         atomic_init(&calls->refcnt, 1);
3119         //TODO: Assign calls->o from o
3120
3121         LDKMessageSendEventsProvider ret = {
3122                 .this_arg = (void*) calls,
3123                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
3124                 .free = LDKMessageSendEventsProvider_JCalls_free,
3125         };
3126         return ret;
3127 }
3128 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3129         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
3130         *res_ptr = LDKMessageSendEventsProvider_init(o);
3131         return (long)res_ptr;
3132 }
3133 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
3134         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
3135         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
3136         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3137         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3138         for (size_t s = 0; s < ret_var.datalen; s++) {
3139                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
3140                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
3141                 long arr_conv_18_ref = (long)arr_conv_18_copy;
3142                 ret_arr_ptr[s] = arr_conv_18_ref;
3143         }
3144         FREE(ret_var.data);
3145         return ret_arr;
3146 }
3147
3148 typedef struct LDKEventsProvider_JCalls {
3149         atomic_size_t refcnt;
3150         uint32_t get_and_clear_pending_events_meth;
3151 } LDKEventsProvider_JCalls;
3152 static void LDKEventsProvider_JCalls_free(void* this_arg) {
3153         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3154         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3155                 js_free(j_calls->get_and_clear_pending_events_meth);
3156                 FREE(j_calls);
3157         }
3158 }
3159 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
3160         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3161         uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
3162         LDKCVec_EventZ arg_constr;
3163         arg_constr.datalen = *((uint32_t*)arg);
3164         if (arg_constr.datalen > 0)
3165                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3166         else
3167                 arg_constr.data = NULL;
3168         uint32_t* arg_vals = (uint32_t*)(arg + 4);
3169         for (size_t h = 0; h < arg_constr.datalen; h++) {
3170                 uint32_t arr_conv_7 = arg_vals[h];
3171                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
3172                 FREE((void*)arr_conv_7);
3173                 arg_constr.data[h] = arr_conv_7_conv;
3174         }
3175         return arg_constr;
3176 }
3177 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
3178         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3179         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3180         return (void*) this_arg;
3181 }
3182 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3183         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
3184         atomic_init(&calls->refcnt, 1);
3185         //TODO: Assign calls->o from o
3186
3187         LDKEventsProvider ret = {
3188                 .this_arg = (void*) calls,
3189                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
3190                 .free = LDKEventsProvider_JCalls_free,
3191         };
3192         return ret;
3193 }
3194 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3195         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
3196         *res_ptr = LDKEventsProvider_init(o);
3197         return (long)res_ptr;
3198 }
3199 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
3200         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
3201         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
3202         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3203         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3204         for (size_t h = 0; h < ret_var.datalen; h++) {
3205                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
3206                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
3207                 long arr_conv_7_ref = (long)arr_conv_7_copy;
3208                 ret_arr_ptr[h] = arr_conv_7_ref;
3209         }
3210         FREE(ret_var.data);
3211         return ret_arr;
3212 }
3213
3214 typedef struct LDKAccess_JCalls {
3215         atomic_size_t refcnt;
3216         uint32_t get_utxo_meth;
3217 } LDKAccess_JCalls;
3218 static void LDKAccess_JCalls_free(void* this_arg) {
3219         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3220         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3221                 js_free(j_calls->get_utxo_meth);
3222                 FREE(j_calls);
3223         }
3224 }
3225 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3226         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3227         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3228         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
3229         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
3230         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)ret;
3231         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
3232         return ret_conv;
3233 }
3234 static void* LDKAccess_JCalls_clone(const void* this_arg) {
3235         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3236         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3237         return (void*) this_arg;
3238 }
3239 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
3240         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3241         atomic_init(&calls->refcnt, 1);
3242         //TODO: Assign calls->o from o
3243
3244         LDKAccess ret = {
3245                 .this_arg = (void*) calls,
3246                 .get_utxo = get_utxo_jcall,
3247                 .free = LDKAccess_JCalls_free,
3248         };
3249         return ret;
3250 }
3251 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
3252         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3253         *res_ptr = LDKAccess_init(o);
3254         return (long)res_ptr;
3255 }
3256 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3257         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
3258         unsigned char genesis_hash_arr[32];
3259         CHECK(*((uint32_t*)genesis_hash) == 32);
3260         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
3261         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3262         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3263         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3264         return (long)ret_conv;
3265 }
3266
3267 typedef struct LDKFilter_JCalls {
3268         atomic_size_t refcnt;
3269         uint32_t register_tx_meth;
3270         uint32_t register_output_meth;
3271 } LDKFilter_JCalls;
3272 static void LDKFilter_JCalls_free(void* this_arg) {
3273         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3274         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3275                 js_free(j_calls->register_tx_meth);
3276                 js_free(j_calls->register_output_meth);
3277                 FREE(j_calls);
3278         }
3279 }
3280 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
3281         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3282         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3283         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
3284         LDKu8slice script_pubkey_var = script_pubkey;
3285         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3286         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3287         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
3288 }
3289 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
3290         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3291         LDKOutPoint outpoint_var = *outpoint;
3292         if (outpoint->inner != NULL)
3293                 outpoint_var = OutPoint_clone(outpoint);
3294         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3295         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3296         long outpoint_ref = (long)outpoint_var.inner;
3297         if (outpoint_var.is_owned) {
3298                 outpoint_ref |= 1;
3299         }
3300         LDKu8slice script_pubkey_var = script_pubkey;
3301         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3302         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3303         js_invoke_function_2(j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
3304 }
3305 static void* LDKFilter_JCalls_clone(const void* this_arg) {
3306         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3307         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3308         return (void*) this_arg;
3309 }
3310 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
3311         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
3312         atomic_init(&calls->refcnt, 1);
3313         //TODO: Assign calls->o from o
3314
3315         LDKFilter ret = {
3316                 .this_arg = (void*) calls,
3317                 .register_tx = register_tx_jcall,
3318                 .register_output = register_output_jcall,
3319                 .free = LDKFilter_JCalls_free,
3320         };
3321         return ret;
3322 }
3323 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
3324         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
3325         *res_ptr = LDKFilter_init(o);
3326         return (long)res_ptr;
3327 }
3328 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
3329         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3330         unsigned char txid_arr[32];
3331         CHECK(*((uint32_t*)txid) == 32);
3332         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
3333         unsigned char (*txid_ref)[32] = &txid_arr;
3334         LDKu8slice script_pubkey_ref;
3335         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3336         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3337         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
3338 }
3339
3340 void  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
3341         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3342         LDKOutPoint outpoint_conv;
3343         outpoint_conv.inner = (void*)(outpoint & (~1));
3344         outpoint_conv.is_owned = false;
3345         LDKu8slice script_pubkey_ref;
3346         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3347         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3348         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
3349 }
3350
3351 typedef struct LDKPersist_JCalls {
3352         atomic_size_t refcnt;
3353         uint32_t persist_new_channel_meth;
3354         uint32_t update_persisted_channel_meth;
3355 } LDKPersist_JCalls;
3356 static void LDKPersist_JCalls_free(void* this_arg) {
3357         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3358         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3359                 js_free(j_calls->persist_new_channel_meth);
3360                 js_free(j_calls->update_persisted_channel_meth);
3361                 FREE(j_calls);
3362         }
3363 }
3364 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
3365         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3366         LDKOutPoint id_var = id;
3367         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3368         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3369         long id_ref = (long)id_var.inner;
3370         if (id_var.is_owned) {
3371                 id_ref |= 1;
3372         }
3373         LDKChannelMonitor data_var = *data;
3374         // Warning: we may need a move here but can't clone!
3375         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3376         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3377         long data_ref = (long)data_var.inner;
3378         if (data_var.is_owned) {
3379                 data_ref |= 1;
3380         }
3381         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
3382         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
3383         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3384         return ret_conv;
3385 }
3386 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
3387         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3388         LDKOutPoint id_var = id;
3389         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3390         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3391         long id_ref = (long)id_var.inner;
3392         if (id_var.is_owned) {
3393                 id_ref |= 1;
3394         }
3395         LDKChannelMonitorUpdate update_var = *update;
3396         if (update->inner != NULL)
3397                 update_var = ChannelMonitorUpdate_clone(update);
3398         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3399         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3400         long update_ref = (long)update_var.inner;
3401         if (update_var.is_owned) {
3402                 update_ref |= 1;
3403         }
3404         LDKChannelMonitor data_var = *data;
3405         // Warning: we may need a move here but can't clone!
3406         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3407         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3408         long data_ref = (long)data_var.inner;
3409         if (data_var.is_owned) {
3410                 data_ref |= 1;
3411         }
3412         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
3413         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
3414         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3415         return ret_conv;
3416 }
3417 static void* LDKPersist_JCalls_clone(const void* this_arg) {
3418         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3419         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3420         return (void*) this_arg;
3421 }
3422 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
3423         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
3424         atomic_init(&calls->refcnt, 1);
3425         //TODO: Assign calls->o from o
3426
3427         LDKPersist ret = {
3428                 .this_arg = (void*) calls,
3429                 .persist_new_channel = persist_new_channel_jcall,
3430                 .update_persisted_channel = update_persisted_channel_jcall,
3431                 .free = LDKPersist_JCalls_free,
3432         };
3433         return ret;
3434 }
3435 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
3436         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
3437         *res_ptr = LDKPersist_init(o);
3438         return (long)res_ptr;
3439 }
3440 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
3441         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3442         LDKOutPoint id_conv;
3443         id_conv.inner = (void*)(id & (~1));
3444         id_conv.is_owned = (id & 1) || (id == 0);
3445         if (id_conv.inner != NULL)
3446                 id_conv = OutPoint_clone(&id_conv);
3447         LDKChannelMonitor data_conv;
3448         data_conv.inner = (void*)(data & (~1));
3449         data_conv.is_owned = false;
3450         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3451         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
3452         return (long)ret_conv;
3453 }
3454
3455 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
3456         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3457         LDKOutPoint id_conv;
3458         id_conv.inner = (void*)(id & (~1));
3459         id_conv.is_owned = (id & 1) || (id == 0);
3460         if (id_conv.inner != NULL)
3461                 id_conv = OutPoint_clone(&id_conv);
3462         LDKChannelMonitorUpdate update_conv;
3463         update_conv.inner = (void*)(update & (~1));
3464         update_conv.is_owned = false;
3465         LDKChannelMonitor data_conv;
3466         data_conv.inner = (void*)(data & (~1));
3467         data_conv.is_owned = false;
3468         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3469         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
3470         return (long)ret_conv;
3471 }
3472
3473 typedef struct LDKChannelMessageHandler_JCalls {
3474         atomic_size_t refcnt;
3475         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
3476         uint32_t handle_open_channel_meth;
3477         uint32_t handle_accept_channel_meth;
3478         uint32_t handle_funding_created_meth;
3479         uint32_t handle_funding_signed_meth;
3480         uint32_t handle_funding_locked_meth;
3481         uint32_t handle_shutdown_meth;
3482         uint32_t handle_closing_signed_meth;
3483         uint32_t handle_update_add_htlc_meth;
3484         uint32_t handle_update_fulfill_htlc_meth;
3485         uint32_t handle_update_fail_htlc_meth;
3486         uint32_t handle_update_fail_malformed_htlc_meth;
3487         uint32_t handle_commitment_signed_meth;
3488         uint32_t handle_revoke_and_ack_meth;
3489         uint32_t handle_update_fee_meth;
3490         uint32_t handle_announcement_signatures_meth;
3491         uint32_t peer_disconnected_meth;
3492         uint32_t peer_connected_meth;
3493         uint32_t handle_channel_reestablish_meth;
3494         uint32_t handle_error_meth;
3495 } LDKChannelMessageHandler_JCalls;
3496 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3497         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3498         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3499                 js_free(j_calls->handle_open_channel_meth);
3500                 js_free(j_calls->handle_accept_channel_meth);
3501                 js_free(j_calls->handle_funding_created_meth);
3502                 js_free(j_calls->handle_funding_signed_meth);
3503                 js_free(j_calls->handle_funding_locked_meth);
3504                 js_free(j_calls->handle_shutdown_meth);
3505                 js_free(j_calls->handle_closing_signed_meth);
3506                 js_free(j_calls->handle_update_add_htlc_meth);
3507                 js_free(j_calls->handle_update_fulfill_htlc_meth);
3508                 js_free(j_calls->handle_update_fail_htlc_meth);
3509                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
3510                 js_free(j_calls->handle_commitment_signed_meth);
3511                 js_free(j_calls->handle_revoke_and_ack_meth);
3512                 js_free(j_calls->handle_update_fee_meth);
3513                 js_free(j_calls->handle_announcement_signatures_meth);
3514                 js_free(j_calls->peer_disconnected_meth);
3515                 js_free(j_calls->peer_connected_meth);
3516                 js_free(j_calls->handle_channel_reestablish_meth);
3517                 js_free(j_calls->handle_error_meth);
3518                 FREE(j_calls);
3519         }
3520 }
3521 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
3522         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3523         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3524         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3525         LDKInitFeatures their_features_var = their_features;
3526         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3527         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3528         long their_features_ref = (long)their_features_var.inner;
3529         if (their_features_var.is_owned) {
3530                 their_features_ref |= 1;
3531         }
3532         LDKOpenChannel msg_var = *msg;
3533         if (msg->inner != NULL)
3534                 msg_var = OpenChannel_clone(msg);
3535         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3536         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3537         long msg_ref = (long)msg_var.inner;
3538         if (msg_var.is_owned) {
3539                 msg_ref |= 1;
3540         }
3541         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3542 }
3543 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
3544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3545         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3546         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3547         LDKInitFeatures their_features_var = their_features;
3548         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3549         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3550         long their_features_ref = (long)their_features_var.inner;
3551         if (their_features_var.is_owned) {
3552                 their_features_ref |= 1;
3553         }
3554         LDKAcceptChannel msg_var = *msg;
3555         if (msg->inner != NULL)
3556                 msg_var = AcceptChannel_clone(msg);
3557         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3558         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3559         long msg_ref = (long)msg_var.inner;
3560         if (msg_var.is_owned) {
3561                 msg_ref |= 1;
3562         }
3563         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3564 }
3565 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
3566         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3567         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3568         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3569         LDKFundingCreated msg_var = *msg;
3570         if (msg->inner != NULL)
3571                 msg_var = FundingCreated_clone(msg);
3572         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3573         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3574         long msg_ref = (long)msg_var.inner;
3575         if (msg_var.is_owned) {
3576                 msg_ref |= 1;
3577         }
3578         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
3579 }
3580 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
3581         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3582         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3583         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3584         LDKFundingSigned msg_var = *msg;
3585         if (msg->inner != NULL)
3586                 msg_var = FundingSigned_clone(msg);
3587         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3588         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3589         long msg_ref = (long)msg_var.inner;
3590         if (msg_var.is_owned) {
3591                 msg_ref |= 1;
3592         }
3593         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
3594 }
3595 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
3596         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3597         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3598         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3599         LDKFundingLocked msg_var = *msg;
3600         if (msg->inner != NULL)
3601                 msg_var = FundingLocked_clone(msg);
3602         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3603         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3604         long msg_ref = (long)msg_var.inner;
3605         if (msg_var.is_owned) {
3606                 msg_ref |= 1;
3607         }
3608         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
3609 }
3610 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
3611         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3612         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3613         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3614         LDKShutdown msg_var = *msg;
3615         if (msg->inner != NULL)
3616                 msg_var = Shutdown_clone(msg);
3617         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3618         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3619         long msg_ref = (long)msg_var.inner;
3620         if (msg_var.is_owned) {
3621                 msg_ref |= 1;
3622         }
3623         js_invoke_function_2(j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
3624 }
3625 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
3626         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3627         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3628         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3629         LDKClosingSigned msg_var = *msg;
3630         if (msg->inner != NULL)
3631                 msg_var = ClosingSigned_clone(msg);
3632         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3633         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3634         long msg_ref = (long)msg_var.inner;
3635         if (msg_var.is_owned) {
3636                 msg_ref |= 1;
3637         }
3638         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
3639 }
3640 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
3641         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3642         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3643         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3644         LDKUpdateAddHTLC msg_var = *msg;
3645         if (msg->inner != NULL)
3646                 msg_var = UpdateAddHTLC_clone(msg);
3647         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3648         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3649         long msg_ref = (long)msg_var.inner;
3650         if (msg_var.is_owned) {
3651                 msg_ref |= 1;
3652         }
3653         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
3654 }
3655 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
3656         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3657         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3658         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3659         LDKUpdateFulfillHTLC msg_var = *msg;
3660         if (msg->inner != NULL)
3661                 msg_var = UpdateFulfillHTLC_clone(msg);
3662         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3663         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3664         long msg_ref = (long)msg_var.inner;
3665         if (msg_var.is_owned) {
3666                 msg_ref |= 1;
3667         }
3668         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
3669 }
3670 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
3671         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3672         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3673         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3674         LDKUpdateFailHTLC msg_var = *msg;
3675         if (msg->inner != NULL)
3676                 msg_var = UpdateFailHTLC_clone(msg);
3677         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3678         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3679         long msg_ref = (long)msg_var.inner;
3680         if (msg_var.is_owned) {
3681                 msg_ref |= 1;
3682         }
3683         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
3684 }
3685 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
3686         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3687         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3688         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3689         LDKUpdateFailMalformedHTLC msg_var = *msg;
3690         if (msg->inner != NULL)
3691                 msg_var = UpdateFailMalformedHTLC_clone(msg);
3692         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3693         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3694         long msg_ref = (long)msg_var.inner;
3695         if (msg_var.is_owned) {
3696                 msg_ref |= 1;
3697         }
3698         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
3699 }
3700 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
3701         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3702         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3703         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3704         LDKCommitmentSigned msg_var = *msg;
3705         if (msg->inner != NULL)
3706                 msg_var = CommitmentSigned_clone(msg);
3707         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3708         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3709         long msg_ref = (long)msg_var.inner;
3710         if (msg_var.is_owned) {
3711                 msg_ref |= 1;
3712         }
3713         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
3714 }
3715 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
3716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3717         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3718         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3719         LDKRevokeAndACK msg_var = *msg;
3720         if (msg->inner != NULL)
3721                 msg_var = RevokeAndACK_clone(msg);
3722         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3723         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3724         long msg_ref = (long)msg_var.inner;
3725         if (msg_var.is_owned) {
3726                 msg_ref |= 1;
3727         }
3728         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
3729 }
3730 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
3731         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3732         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3733         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3734         LDKUpdateFee msg_var = *msg;
3735         if (msg->inner != NULL)
3736                 msg_var = UpdateFee_clone(msg);
3737         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3738         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3739         long msg_ref = (long)msg_var.inner;
3740         if (msg_var.is_owned) {
3741                 msg_ref |= 1;
3742         }
3743         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
3744 }
3745 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
3746         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3747         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3748         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3749         LDKAnnouncementSignatures msg_var = *msg;
3750         if (msg->inner != NULL)
3751                 msg_var = AnnouncementSignatures_clone(msg);
3752         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3753         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3754         long msg_ref = (long)msg_var.inner;
3755         if (msg_var.is_owned) {
3756                 msg_ref |= 1;
3757         }
3758         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
3759 }
3760 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3761         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3762         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3763         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3764         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3765 }
3766 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
3767         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3768         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3769         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3770         LDKInit msg_var = *msg;
3771         if (msg->inner != NULL)
3772                 msg_var = Init_clone(msg);
3773         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3774         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3775         long msg_ref = (long)msg_var.inner;
3776         if (msg_var.is_owned) {
3777                 msg_ref |= 1;
3778         }
3779         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
3780 }
3781 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
3782         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3783         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3784         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3785         LDKChannelReestablish msg_var = *msg;
3786         if (msg->inner != NULL)
3787                 msg_var = ChannelReestablish_clone(msg);
3788         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3789         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3790         long msg_ref = (long)msg_var.inner;
3791         if (msg_var.is_owned) {
3792                 msg_ref |= 1;
3793         }
3794         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
3795 }
3796 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
3797         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3798         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3799         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3800         LDKErrorMessage msg_var = *msg;
3801         if (msg->inner != NULL)
3802                 msg_var = ErrorMessage_clone(msg);
3803         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3804         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3805         long msg_ref = (long)msg_var.inner;
3806         if (msg_var.is_owned) {
3807                 msg_ref |= 1;
3808         }
3809         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
3810 }
3811 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3813         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3814         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3815         return (void*) this_arg;
3816 }
3817 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
3818         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3819         atomic_init(&calls->refcnt, 1);
3820         //TODO: Assign calls->o from o
3821
3822         LDKChannelMessageHandler ret = {
3823                 .this_arg = (void*) calls,
3824                 .handle_open_channel = handle_open_channel_jcall,
3825                 .handle_accept_channel = handle_accept_channel_jcall,
3826                 .handle_funding_created = handle_funding_created_jcall,
3827                 .handle_funding_signed = handle_funding_signed_jcall,
3828                 .handle_funding_locked = handle_funding_locked_jcall,
3829                 .handle_shutdown = handle_shutdown_jcall,
3830                 .handle_closing_signed = handle_closing_signed_jcall,
3831                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3832                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3833                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3834                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3835                 .handle_commitment_signed = handle_commitment_signed_jcall,
3836                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3837                 .handle_update_fee = handle_update_fee_jcall,
3838                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3839                 .peer_disconnected = peer_disconnected_jcall,
3840                 .peer_connected = peer_connected_jcall,
3841                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3842                 .handle_error = handle_error_jcall,
3843                 .free = LDKChannelMessageHandler_JCalls_free,
3844                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
3845         };
3846         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3847         return ret;
3848 }
3849 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
3850         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3851         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
3852         return (long)res_ptr;
3853 }
3854 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) {
3855         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3856         LDKPublicKey their_node_id_ref;
3857         CHECK(*((uint32_t*)their_node_id) == 33);
3858         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3859         LDKInitFeatures their_features_conv;
3860         their_features_conv.inner = (void*)(their_features & (~1));
3861         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3862         // Warning: we may need a move here but can't clone!
3863         LDKOpenChannel msg_conv;
3864         msg_conv.inner = (void*)(msg & (~1));
3865         msg_conv.is_owned = false;
3866         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3867 }
3868
3869 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) {
3870         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3871         LDKPublicKey their_node_id_ref;
3872         CHECK(*((uint32_t*)their_node_id) == 33);
3873         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3874         LDKInitFeatures their_features_conv;
3875         their_features_conv.inner = (void*)(their_features & (~1));
3876         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3877         // Warning: we may need a move here but can't clone!
3878         LDKAcceptChannel msg_conv;
3879         msg_conv.inner = (void*)(msg & (~1));
3880         msg_conv.is_owned = false;
3881         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3882 }
3883
3884 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3885         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3886         LDKPublicKey their_node_id_ref;
3887         CHECK(*((uint32_t*)their_node_id) == 33);
3888         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3889         LDKFundingCreated msg_conv;
3890         msg_conv.inner = (void*)(msg & (~1));
3891         msg_conv.is_owned = false;
3892         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3893 }
3894
3895 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3896         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3897         LDKPublicKey their_node_id_ref;
3898         CHECK(*((uint32_t*)their_node_id) == 33);
3899         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3900         LDKFundingSigned msg_conv;
3901         msg_conv.inner = (void*)(msg & (~1));
3902         msg_conv.is_owned = false;
3903         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3904 }
3905
3906 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3907         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3908         LDKPublicKey their_node_id_ref;
3909         CHECK(*((uint32_t*)their_node_id) == 33);
3910         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3911         LDKFundingLocked msg_conv;
3912         msg_conv.inner = (void*)(msg & (~1));
3913         msg_conv.is_owned = false;
3914         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3915 }
3916
3917 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3918         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3919         LDKPublicKey their_node_id_ref;
3920         CHECK(*((uint32_t*)their_node_id) == 33);
3921         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3922         LDKShutdown msg_conv;
3923         msg_conv.inner = (void*)(msg & (~1));
3924         msg_conv.is_owned = false;
3925         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3926 }
3927
3928 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3929         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3930         LDKPublicKey their_node_id_ref;
3931         CHECK(*((uint32_t*)their_node_id) == 33);
3932         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3933         LDKClosingSigned msg_conv;
3934         msg_conv.inner = (void*)(msg & (~1));
3935         msg_conv.is_owned = false;
3936         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3937 }
3938
3939 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3940         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3941         LDKPublicKey their_node_id_ref;
3942         CHECK(*((uint32_t*)their_node_id) == 33);
3943         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3944         LDKUpdateAddHTLC msg_conv;
3945         msg_conv.inner = (void*)(msg & (~1));
3946         msg_conv.is_owned = false;
3947         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3948 }
3949
3950 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3951         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3952         LDKPublicKey their_node_id_ref;
3953         CHECK(*((uint32_t*)their_node_id) == 33);
3954         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3955         LDKUpdateFulfillHTLC msg_conv;
3956         msg_conv.inner = (void*)(msg & (~1));
3957         msg_conv.is_owned = false;
3958         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3959 }
3960
3961 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3962         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3963         LDKPublicKey their_node_id_ref;
3964         CHECK(*((uint32_t*)their_node_id) == 33);
3965         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3966         LDKUpdateFailHTLC msg_conv;
3967         msg_conv.inner = (void*)(msg & (~1));
3968         msg_conv.is_owned = false;
3969         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3970 }
3971
3972 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3973         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3974         LDKPublicKey their_node_id_ref;
3975         CHECK(*((uint32_t*)their_node_id) == 33);
3976         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3977         LDKUpdateFailMalformedHTLC msg_conv;
3978         msg_conv.inner = (void*)(msg & (~1));
3979         msg_conv.is_owned = false;
3980         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3981 }
3982
3983 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3984         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3985         LDKPublicKey their_node_id_ref;
3986         CHECK(*((uint32_t*)their_node_id) == 33);
3987         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3988         LDKCommitmentSigned msg_conv;
3989         msg_conv.inner = (void*)(msg & (~1));
3990         msg_conv.is_owned = false;
3991         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3992 }
3993
3994 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3995         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3996         LDKPublicKey their_node_id_ref;
3997         CHECK(*((uint32_t*)their_node_id) == 33);
3998         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3999         LDKRevokeAndACK msg_conv;
4000         msg_conv.inner = (void*)(msg & (~1));
4001         msg_conv.is_owned = false;
4002         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4003 }
4004
4005 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4006         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4007         LDKPublicKey their_node_id_ref;
4008         CHECK(*((uint32_t*)their_node_id) == 33);
4009         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4010         LDKUpdateFee msg_conv;
4011         msg_conv.inner = (void*)(msg & (~1));
4012         msg_conv.is_owned = false;
4013         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4014 }
4015
4016 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4017         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4018         LDKPublicKey their_node_id_ref;
4019         CHECK(*((uint32_t*)their_node_id) == 33);
4020         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4021         LDKAnnouncementSignatures msg_conv;
4022         msg_conv.inner = (void*)(msg & (~1));
4023         msg_conv.is_owned = false;
4024         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4025 }
4026
4027 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
4028         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4029         LDKPublicKey their_node_id_ref;
4030         CHECK(*((uint32_t*)their_node_id) == 33);
4031         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4032         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
4033 }
4034
4035 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4036         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4037         LDKPublicKey their_node_id_ref;
4038         CHECK(*((uint32_t*)their_node_id) == 33);
4039         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4040         LDKInit msg_conv;
4041         msg_conv.inner = (void*)(msg & (~1));
4042         msg_conv.is_owned = false;
4043         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4044 }
4045
4046 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4047         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4048         LDKPublicKey their_node_id_ref;
4049         CHECK(*((uint32_t*)their_node_id) == 33);
4050         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4051         LDKChannelReestablish msg_conv;
4052         msg_conv.inner = (void*)(msg & (~1));
4053         msg_conv.is_owned = false;
4054         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4055 }
4056
4057 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4058         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4059         LDKPublicKey their_node_id_ref;
4060         CHECK(*((uint32_t*)their_node_id) == 33);
4061         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4062         LDKErrorMessage msg_conv;
4063         msg_conv.inner = (void*)(msg & (~1));
4064         msg_conv.is_owned = false;
4065         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4066 }
4067
4068 typedef struct LDKRoutingMessageHandler_JCalls {
4069         atomic_size_t refcnt;
4070         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4071         uint32_t handle_node_announcement_meth;
4072         uint32_t handle_channel_announcement_meth;
4073         uint32_t handle_channel_update_meth;
4074         uint32_t handle_htlc_fail_channel_update_meth;
4075         uint32_t get_next_channel_announcements_meth;
4076         uint32_t get_next_node_announcements_meth;
4077         uint32_t sync_routing_table_meth;
4078         uint32_t handle_reply_channel_range_meth;
4079         uint32_t handle_reply_short_channel_ids_end_meth;
4080         uint32_t handle_query_channel_range_meth;
4081         uint32_t handle_query_short_channel_ids_meth;
4082 } LDKRoutingMessageHandler_JCalls;
4083 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
4084         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4085         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4086                 js_free(j_calls->handle_node_announcement_meth);
4087                 js_free(j_calls->handle_channel_announcement_meth);
4088                 js_free(j_calls->handle_channel_update_meth);
4089                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
4090                 js_free(j_calls->get_next_channel_announcements_meth);
4091                 js_free(j_calls->get_next_node_announcements_meth);
4092                 js_free(j_calls->sync_routing_table_meth);
4093                 js_free(j_calls->handle_reply_channel_range_meth);
4094                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
4095                 js_free(j_calls->handle_query_channel_range_meth);
4096                 js_free(j_calls->handle_query_short_channel_ids_meth);
4097                 FREE(j_calls);
4098         }
4099 }
4100 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
4101         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4102         LDKNodeAnnouncement msg_var = *msg;
4103         if (msg->inner != NULL)
4104                 msg_var = NodeAnnouncement_clone(msg);
4105         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4106         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4107         long msg_ref = (long)msg_var.inner;
4108         if (msg_var.is_owned) {
4109                 msg_ref |= 1;
4110         }
4111         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
4112         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4113         // Warning: we may need a move here but can't do a full clone!
4114         return ret_conv;
4115 }
4116 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
4117         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4118         LDKChannelAnnouncement msg_var = *msg;
4119         if (msg->inner != NULL)
4120                 msg_var = ChannelAnnouncement_clone(msg);
4121         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4122         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4123         long msg_ref = (long)msg_var.inner;
4124         if (msg_var.is_owned) {
4125                 msg_ref |= 1;
4126         }
4127         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
4128         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4129         // Warning: we may need a move here but can't do a full clone!
4130         return ret_conv;
4131 }
4132 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
4133         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4134         LDKChannelUpdate msg_var = *msg;
4135         if (msg->inner != NULL)
4136                 msg_var = ChannelUpdate_clone(msg);
4137         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4138         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4139         long msg_ref = (long)msg_var.inner;
4140         if (msg_var.is_owned) {
4141                 msg_ref |= 1;
4142         }
4143         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
4144         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4145         // Warning: we may need a move here but can't do a full clone!
4146         return ret_conv;
4147 }
4148 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
4149         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4150         long ret_update = (long)update;
4151         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
4152 }
4153 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
4154         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4155         uint32_tArray arg = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
4156         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
4157         arg_constr.datalen = *((uint32_t*)arg);
4158         if (arg_constr.datalen > 0)
4159                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4160         else
4161                 arg_constr.data = NULL;
4162         uint32_t* arg_vals = (uint32_t*)(arg + 4);
4163         for (size_t l = 0; l < arg_constr.datalen; l++) {
4164                 uint32_t arr_conv_63 = arg_vals[l];
4165                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4166                 FREE((void*)arr_conv_63);
4167                 arg_constr.data[l] = arr_conv_63_conv;
4168         }
4169         return arg_constr;
4170 }
4171 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
4172         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4173         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4174         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
4175         uint32_tArray arg = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
4176         LDKCVec_NodeAnnouncementZ arg_constr;
4177         arg_constr.datalen = *((uint32_t*)arg);
4178         if (arg_constr.datalen > 0)
4179                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4180         else
4181                 arg_constr.data = NULL;
4182         uint32_t* arg_vals = (uint32_t*)(arg + 4);
4183         for (size_t s = 0; s < arg_constr.datalen; s++) {
4184                 uint32_t arr_conv_18 = arg_vals[s];
4185                 LDKNodeAnnouncement arr_conv_18_conv;
4186                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4187                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4188                 if (arr_conv_18_conv.inner != NULL)
4189                         arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
4190                 arg_constr.data[s] = arr_conv_18_conv;
4191         }
4192         return arg_constr;
4193 }
4194 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
4195         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4196         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4197         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4198         LDKInit init_var = *init;
4199         if (init->inner != NULL)
4200                 init_var = Init_clone(init);
4201         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4202         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4203         long init_ref = (long)init_var.inner;
4204         if (init_var.is_owned) {
4205                 init_ref |= 1;
4206         }
4207         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
4208 }
4209 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
4210         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4211         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4212         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4213         LDKReplyChannelRange msg_var = msg;
4214         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4215         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4216         long msg_ref = (long)msg_var.inner;
4217         if (msg_var.is_owned) {
4218                 msg_ref |= 1;
4219         }
4220         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
4221         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4222         // Warning: we may need a move here but can't do a full clone!
4223         return ret_conv;
4224 }
4225 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
4226         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4227         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4228         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4229         LDKReplyShortChannelIdsEnd msg_var = msg;
4230         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4231         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4232         long msg_ref = (long)msg_var.inner;
4233         if (msg_var.is_owned) {
4234                 msg_ref |= 1;
4235         }
4236         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
4237         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4238         // Warning: we may need a move here but can't do a full clone!
4239         return ret_conv;
4240 }
4241 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
4242         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4243         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4244         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4245         LDKQueryChannelRange msg_var = msg;
4246         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4247         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4248         long msg_ref = (long)msg_var.inner;
4249         if (msg_var.is_owned) {
4250                 msg_ref |= 1;
4251         }
4252         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
4253         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4254         // Warning: we may need a move here but can't do a full clone!
4255         return ret_conv;
4256 }
4257 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
4258         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4259         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4260         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4261         LDKQueryShortChannelIds msg_var = msg;
4262         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4263         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4264         long msg_ref = (long)msg_var.inner;
4265         if (msg_var.is_owned) {
4266                 msg_ref |= 1;
4267         }
4268         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
4269         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4270         // Warning: we may need a move here but can't do a full clone!
4271         return ret_conv;
4272 }
4273 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
4274         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4275         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4276         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4277         return (void*) this_arg;
4278 }
4279 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4280         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
4281         atomic_init(&calls->refcnt, 1);
4282         //TODO: Assign calls->o from o
4283
4284         LDKRoutingMessageHandler ret = {
4285                 .this_arg = (void*) calls,
4286                 .handle_node_announcement = handle_node_announcement_jcall,
4287                 .handle_channel_announcement = handle_channel_announcement_jcall,
4288                 .handle_channel_update = handle_channel_update_jcall,
4289                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
4290                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
4291                 .get_next_node_announcements = get_next_node_announcements_jcall,
4292                 .sync_routing_table = sync_routing_table_jcall,
4293                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
4294                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
4295                 .handle_query_channel_range = handle_query_channel_range_jcall,
4296                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
4297                 .free = LDKRoutingMessageHandler_JCalls_free,
4298                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4299         };
4300         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4301         return ret;
4302 }
4303 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4304         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
4305         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
4306         return (long)res_ptr;
4307 }
4308 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
4309         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4310         LDKNodeAnnouncement msg_conv;
4311         msg_conv.inner = (void*)(msg & (~1));
4312         msg_conv.is_owned = false;
4313         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4314         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
4315         return (long)ret_conv;
4316 }
4317
4318 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
4319         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4320         LDKChannelAnnouncement msg_conv;
4321         msg_conv.inner = (void*)(msg & (~1));
4322         msg_conv.is_owned = false;
4323         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4324         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4325         return (long)ret_conv;
4326 }
4327
4328 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
4329         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4330         LDKChannelUpdate msg_conv;
4331         msg_conv.inner = (void*)(msg & (~1));
4332         msg_conv.is_owned = false;
4333         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4334         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
4335         return (long)ret_conv;
4336 }
4337
4338 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
4339         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4340         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
4341         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
4342 }
4343
4344 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
4345         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4346         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
4347         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4348         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4349         for (size_t l = 0; l < ret_var.datalen; l++) {
4350                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4351                 *arr_conv_63_ref = ret_var.data[l];
4352                 arr_conv_63_ref->a = ChannelAnnouncement_clone(&arr_conv_63_ref->a);
4353                 arr_conv_63_ref->b = ChannelUpdate_clone(&arr_conv_63_ref->b);
4354                 arr_conv_63_ref->c = ChannelUpdate_clone(&arr_conv_63_ref->c);
4355                 ret_arr_ptr[l] = (long)arr_conv_63_ref;
4356         }
4357         FREE(ret_var.data);
4358         return ret_arr;
4359 }
4360
4361 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
4362         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4363         LDKPublicKey starting_point_ref;
4364         CHECK(*((uint32_t*)starting_point) == 33);
4365         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
4366         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
4367         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4368         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4369         for (size_t s = 0; s < ret_var.datalen; s++) {
4370                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
4371                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4372                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4373                 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
4374                 if (arr_conv_18_var.is_owned) {
4375                         arr_conv_18_ref |= 1;
4376                 }
4377                 ret_arr_ptr[s] = arr_conv_18_ref;
4378         }
4379         FREE(ret_var.data);
4380         return ret_arr;
4381 }
4382
4383 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
4384         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4385         LDKPublicKey their_node_id_ref;
4386         CHECK(*((uint32_t*)their_node_id) == 33);
4387         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4388         LDKInit init_conv;
4389         init_conv.inner = (void*)(init & (~1));
4390         init_conv.is_owned = false;
4391         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
4392 }
4393
4394 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4395         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4396         LDKPublicKey their_node_id_ref;
4397         CHECK(*((uint32_t*)their_node_id) == 33);
4398         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4399         LDKReplyChannelRange msg_conv;
4400         msg_conv.inner = (void*)(msg & (~1));
4401         msg_conv.is_owned = (msg & 1) || (msg == 0);
4402         if (msg_conv.inner != NULL)
4403                 msg_conv = ReplyChannelRange_clone(&msg_conv);
4404         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4405         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4406         return (long)ret_conv;
4407 }
4408
4409 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) {
4410         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4411         LDKPublicKey their_node_id_ref;
4412         CHECK(*((uint32_t*)their_node_id) == 33);
4413         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4414         LDKReplyShortChannelIdsEnd msg_conv;
4415         msg_conv.inner = (void*)(msg & (~1));
4416         msg_conv.is_owned = (msg & 1) || (msg == 0);
4417         if (msg_conv.inner != NULL)
4418                 msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
4419         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4420         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4421         return (long)ret_conv;
4422 }
4423
4424 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4425         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4426         LDKPublicKey their_node_id_ref;
4427         CHECK(*((uint32_t*)their_node_id) == 33);
4428         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4429         LDKQueryChannelRange msg_conv;
4430         msg_conv.inner = (void*)(msg & (~1));
4431         msg_conv.is_owned = (msg & 1) || (msg == 0);
4432         if (msg_conv.inner != NULL)
4433                 msg_conv = QueryChannelRange_clone(&msg_conv);
4434         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4435         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4436         return (long)ret_conv;
4437 }
4438
4439 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4440         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4441         LDKPublicKey their_node_id_ref;
4442         CHECK(*((uint32_t*)their_node_id) == 33);
4443         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4444         LDKQueryShortChannelIds msg_conv;
4445         msg_conv.inner = (void*)(msg & (~1));
4446         msg_conv.is_owned = (msg & 1) || (msg == 0);
4447         if (msg_conv.inner != NULL)
4448                 msg_conv = QueryShortChannelIds_clone(&msg_conv);
4449         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4450         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4451         return (long)ret_conv;
4452 }
4453
4454 typedef struct LDKSocketDescriptor_JCalls {
4455         atomic_size_t refcnt;
4456         uint32_t send_data_meth;
4457         uint32_t disconnect_socket_meth;
4458         uint32_t eq_meth;
4459         uint32_t hash_meth;
4460 } LDKSocketDescriptor_JCalls;
4461 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
4462         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4463         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4464                 js_free(j_calls->send_data_meth);
4465                 js_free(j_calls->disconnect_socket_meth);
4466                 js_free(j_calls->eq_meth);
4467                 js_free(j_calls->hash_meth);
4468                 FREE(j_calls);
4469         }
4470 }
4471 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
4472         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4473         LDKu8slice data_var = data;
4474         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4475         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
4476         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
4477 }
4478 void disconnect_socket_jcall(void* this_arg) {
4479         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4480         js_invoke_function_0(j_calls->disconnect_socket_meth);
4481 }
4482 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
4483         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4484         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4485         *other_arg_clone = SocketDescriptor_clone(other_arg);
4486         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
4487 }
4488 uint64_t hash_jcall(const void* this_arg) {
4489         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4490         return js_invoke_function_0(j_calls->hash_meth);
4491 }
4492 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
4493         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4495         return (void*) this_arg;
4496 }
4497 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
4498         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
4499         atomic_init(&calls->refcnt, 1);
4500         //TODO: Assign calls->o from o
4501
4502         LDKSocketDescriptor ret = {
4503                 .this_arg = (void*) calls,
4504                 .send_data = send_data_jcall,
4505                 .disconnect_socket = disconnect_socket_jcall,
4506                 .eq = eq_jcall,
4507                 .hash = hash_jcall,
4508                 .clone = LDKSocketDescriptor_JCalls_clone,
4509                 .free = LDKSocketDescriptor_JCalls_free,
4510         };
4511         return ret;
4512 }
4513 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
4514         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4515         *res_ptr = LDKSocketDescriptor_init(o);
4516         return (long)res_ptr;
4517 }
4518 intptr_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
4519         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4520         LDKu8slice data_ref;
4521         data_ref.datalen = *((uint32_t*)data);
4522         data_ref.data = (int8_t*)(data + 4);
4523         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
4524         return ret_val;
4525 }
4526
4527 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
4528         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4529         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4530 }
4531
4532 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
4533         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4534         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4535         return ret_val;
4536 }
4537
4538 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
4539         LDKTransaction _res_ref;
4540         _res_ref.datalen = *((uint32_t*)_res);
4541         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
4542         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
4543         _res_ref.data_is_owned = true;
4544         Transaction_free(_res_ref);
4545 }
4546
4547 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
4548         LDKTxOut _res_conv = *(LDKTxOut*)_res;
4549         FREE((void*)_res);
4550         TxOut_free(_res_conv);
4551 }
4552
4553 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
4554         LDKTxOut* orig_conv = (LDKTxOut*)orig;
4555         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4556         *ret_ref = TxOut_clone(orig_conv);
4557         return (long)ret_ref;
4558 }
4559
4560 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
4561         LDKCVec_SpendableOutputDescriptorZ _res_constr;
4562         _res_constr.datalen = *((uint32_t*)_res);
4563         if (_res_constr.datalen > 0)
4564                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
4565         else
4566                 _res_constr.data = NULL;
4567         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4568         for (size_t b = 0; b < _res_constr.datalen; b++) {
4569                 uint32_t arr_conv_27 = _res_vals[b];
4570                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
4571                 FREE((void*)arr_conv_27);
4572                 _res_constr.data[b] = arr_conv_27_conv;
4573         }
4574         CVec_SpendableOutputDescriptorZ_free(_res_constr);
4575 }
4576
4577 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
4578         LDKCVec_MessageSendEventZ _res_constr;
4579         _res_constr.datalen = *((uint32_t*)_res);
4580         if (_res_constr.datalen > 0)
4581                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4582         else
4583                 _res_constr.data = NULL;
4584         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4585         for (size_t s = 0; s < _res_constr.datalen; s++) {
4586                 uint32_t arr_conv_18 = _res_vals[s];
4587                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
4588                 FREE((void*)arr_conv_18);
4589                 _res_constr.data[s] = arr_conv_18_conv;
4590         }
4591         CVec_MessageSendEventZ_free(_res_constr);
4592 }
4593
4594 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
4595         LDKCVec_EventZ _res_constr;
4596         _res_constr.datalen = *((uint32_t*)_res);
4597         if (_res_constr.datalen > 0)
4598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4599         else
4600                 _res_constr.data = NULL;
4601         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4602         for (size_t h = 0; h < _res_constr.datalen; h++) {
4603                 uint32_t arr_conv_7 = _res_vals[h];
4604                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
4605                 FREE((void*)arr_conv_7);
4606                 _res_constr.data[h] = arr_conv_7_conv;
4607         }
4608         CVec_EventZ_free(_res_constr);
4609 }
4610
4611 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
4612         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)_res;
4613         FREE((void*)_res);
4614         C2Tuple_usizeTransactionZ_free(_res_conv);
4615 }
4616
4617 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
4618         LDKTransaction b_ref;
4619         b_ref.datalen = *((uint32_t*)b);
4620         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
4621         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4622         b_ref.data_is_owned = true;
4623         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4624         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
4625         // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array
4626         return (long)ret_ref;
4627 }
4628
4629 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
4630         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
4631         _res_constr.datalen = *((uint32_t*)_res);
4632         if (_res_constr.datalen > 0)
4633                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4634         else
4635                 _res_constr.data = NULL;
4636         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4637         for (size_t e = 0; e < _res_constr.datalen; e++) {
4638                 uint32_t arr_conv_30 = _res_vals[e];
4639                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
4640                 FREE((void*)arr_conv_30);
4641                 _res_constr.data[e] = arr_conv_30_conv;
4642         }
4643         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
4644 }
4645
4646 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
4647         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4648         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
4649         return (long)ret_conv;
4650 }
4651
4652 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
4653         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
4654         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4655         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
4656         return (long)ret_conv;
4657 }
4658
4659 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
4660         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)_res;
4661         FREE((void*)_res);
4662         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
4663 }
4664
4665 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
4666         LDKCVec_MonitorEventZ _res_constr;
4667         _res_constr.datalen = *((uint32_t*)_res);
4668         if (_res_constr.datalen > 0)
4669                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4670         else
4671                 _res_constr.data = NULL;
4672         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4673         for (size_t o = 0; o < _res_constr.datalen; o++) {
4674                 uint32_t arr_conv_14 = _res_vals[o];
4675                 LDKMonitorEvent arr_conv_14_conv;
4676                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4677                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4678                 _res_constr.data[o] = arr_conv_14_conv;
4679         }
4680         CVec_MonitorEventZ_free(_res_constr);
4681 }
4682
4683 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
4684         LDKChannelMonitorUpdate o_conv;
4685         o_conv.inner = (void*)(o & (~1));
4686         o_conv.is_owned = (o & 1) || (o == 0);
4687         if (o_conv.inner != NULL)
4688                 o_conv = ChannelMonitorUpdate_clone(&o_conv);
4689         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4690         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
4691         return (long)ret_conv;
4692 }
4693
4694 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
4695         LDKDecodeError e_conv;
4696         e_conv.inner = (void*)(e & (~1));
4697         e_conv.is_owned = (e & 1) || (e == 0);
4698         // Warning: we may need a move here but can't clone!
4699         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4700         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
4701         return (long)ret_conv;
4702 }
4703
4704 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
4705         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)_res;
4706         FREE((void*)_res);
4707         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
4708 }
4709
4710 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
4711         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4712         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
4713         return (long)ret_conv;
4714 }
4715
4716 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
4717         LDKMonitorUpdateError e_conv;
4718         e_conv.inner = (void*)(e & (~1));
4719         e_conv.is_owned = (e & 1) || (e == 0);
4720         // Warning: we may need a move here but can't clone!
4721         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4722         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
4723         return (long)ret_conv;
4724 }
4725
4726 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
4727         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)_res;
4728         FREE((void*)_res);
4729         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
4730 }
4731
4732 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
4733         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)_res;
4734         FREE((void*)_res);
4735         C2Tuple_OutPointScriptZ_free(_res_conv);
4736 }
4737
4738 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
4739         LDKOutPoint a_conv;
4740         a_conv.inner = (void*)(a & (~1));
4741         a_conv.is_owned = (a & 1) || (a == 0);
4742         if (a_conv.inner != NULL)
4743                 a_conv = OutPoint_clone(&a_conv);
4744         LDKCVec_u8Z b_ref;
4745         b_ref.datalen = *((uint32_t*)b);
4746         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4747         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4748         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4749         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
4750         ret_ref->a = OutPoint_clone(&ret_ref->a);
4751         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
4752         return (long)ret_ref;
4753 }
4754
4755 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
4756         LDKCVec_TransactionZ _res_constr;
4757         _res_constr.datalen = *((uint32_t*)_res);
4758         if (_res_constr.datalen > 0)
4759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
4760         else
4761                 _res_constr.data = NULL;
4762         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4763         for (size_t m = 0; m < _res_constr.datalen; m++) {
4764                 int8_tArray arr_conv_12 = _res_vals[m];
4765                 LDKTransaction arr_conv_12_ref;
4766                 arr_conv_12_ref.datalen = *((uint32_t*)arr_conv_12);
4767                 arr_conv_12_ref.data = MALLOC(arr_conv_12_ref.datalen, "LDKTransaction Bytes");
4768                 memcpy(arr_conv_12_ref.data, (uint8_t*)(arr_conv_12 + 4), arr_conv_12_ref.datalen);
4769                 arr_conv_12_ref.data_is_owned = true;
4770                 _res_constr.data[m] = arr_conv_12_ref;
4771         }
4772         CVec_TransactionZ_free(_res_constr);
4773 }
4774
4775 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
4776         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)_res;
4777         FREE((void*)_res);
4778         C2Tuple_u32TxOutZ_free(_res_conv);
4779 }
4780
4781 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
4782         LDKTxOut b_conv = *(LDKTxOut*)b;
4783         FREE((void*)b);
4784         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4785         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
4786         ret_ref->b = TxOut_clone(&ret_ref->b);
4787         return (long)ret_ref;
4788 }
4789
4790 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
4791         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
4792         _res_constr.datalen = *((uint32_t*)_res);
4793         if (_res_constr.datalen > 0)
4794                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4795         else
4796                 _res_constr.data = NULL;
4797         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4798         for (size_t z = 0; z < _res_constr.datalen; z++) {
4799                 uint32_t arr_conv_25 = _res_vals[z];
4800                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
4801                 FREE((void*)arr_conv_25);
4802                 _res_constr.data[z] = arr_conv_25_conv;
4803         }
4804         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
4805 }
4806
4807 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
4808         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)_res;
4809         FREE((void*)_res);
4810         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
4811 }
4812
4813 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
4814         LDKThirtyTwoBytes a_ref;
4815         CHECK(*((uint32_t*)a) == 32);
4816         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4817         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4818         b_constr.datalen = *((uint32_t*)b);
4819         if (b_constr.datalen > 0)
4820                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4821         else
4822                 b_constr.data = NULL;
4823         uint32_t* b_vals = (uint32_t*)(b + 4);
4824         for (size_t z = 0; z < b_constr.datalen; z++) {
4825                 uint32_t arr_conv_25 = b_vals[z];
4826                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
4827                 FREE((void*)arr_conv_25);
4828                 b_constr.data[z] = arr_conv_25_conv;
4829         }
4830         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4831         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
4832         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
4833         ret_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&ret_ref->b);
4834         return (long)ret_ref;
4835 }
4836
4837 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
4838         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
4839         _res_constr.datalen = *((uint32_t*)_res);
4840         if (_res_constr.datalen > 0)
4841                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
4842         else
4843                 _res_constr.data = NULL;
4844         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4845         for (size_t x = 0; x < _res_constr.datalen; x++) {
4846                 uint32_t arr_conv_49 = _res_vals[x];
4847                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_conv_49;
4848                 FREE((void*)arr_conv_49);
4849                 _res_constr.data[x] = arr_conv_49_conv;
4850         }
4851         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
4852 }
4853
4854 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
4855         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)_res;
4856         FREE((void*)_res);
4857         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
4858 }
4859
4860 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
4861         LDKThirtyTwoBytes a_ref;
4862         CHECK(*((uint32_t*)a) == 32);
4863         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4864         LDKChannelMonitor b_conv;
4865         b_conv.inner = (void*)(b & (~1));
4866         b_conv.is_owned = (b & 1) || (b == 0);
4867         // Warning: we may need a move here but can't clone!
4868         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4869         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
4870         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
4871         // XXX: We likely need to clone here, but no _clone fn is available for ChannelMonitor
4872         return (long)ret_ref;
4873 }
4874
4875 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
4876         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)o;
4877         FREE((void*)o);
4878         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4879         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
4880         return (long)ret_conv;
4881 }
4882
4883 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
4884         LDKDecodeError e_conv;
4885         e_conv.inner = (void*)(e & (~1));
4886         e_conv.is_owned = (e & 1) || (e == 0);
4887         // Warning: we may need a move here but can't clone!
4888         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4889         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
4890         return (long)ret_conv;
4891 }
4892
4893 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
4894         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)_res;
4895         FREE((void*)_res);
4896         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
4897 }
4898
4899 void  __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
4900         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)_res;
4901         FREE((void*)_res);
4902         C2Tuple_u64u64Z_free(_res_conv);
4903 }
4904
4905 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
4906         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4907         *ret_ref = C2Tuple_u64u64Z_new(a, b);
4908         return (long)ret_ref;
4909 }
4910
4911 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
4912         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)o;
4913         FREE((void*)o);
4914         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4915         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
4916         return (long)ret_conv;
4917 }
4918
4919 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
4920         LDKDecodeError e_conv;
4921         e_conv.inner = (void*)(e & (~1));
4922         e_conv.is_owned = (e & 1) || (e == 0);
4923         // Warning: we may need a move here but can't clone!
4924         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4925         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
4926         return (long)ret_conv;
4927 }
4928
4929 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
4930         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)_res;
4931         FREE((void*)_res);
4932         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
4933 }
4934
4935 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
4936         LDKCVec_SignatureZ _res_constr;
4937         _res_constr.datalen = *((uint32_t*)_res);
4938         if (_res_constr.datalen > 0)
4939                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4940         else
4941                 _res_constr.data = NULL;
4942         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4943         for (size_t m = 0; m < _res_constr.datalen; m++) {
4944                 int8_tArray arr_conv_12 = _res_vals[m];
4945                 LDKSignature arr_conv_12_ref;
4946                 CHECK(*((uint32_t*)arr_conv_12) == 64);
4947                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4948                 _res_constr.data[m] = arr_conv_12_ref;
4949         }
4950         CVec_SignatureZ_free(_res_constr);
4951 }
4952
4953 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
4954         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)_res;
4955         FREE((void*)_res);
4956         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
4957 }
4958
4959 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
4960         LDKSignature a_ref;
4961         CHECK(*((uint32_t*)a) == 64);
4962         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
4963         LDKCVec_SignatureZ b_constr;
4964         b_constr.datalen = *((uint32_t*)b);
4965         if (b_constr.datalen > 0)
4966                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4967         else
4968                 b_constr.data = NULL;
4969         int8_tArray* b_vals = (int8_tArray*)(b + 4);
4970         for (size_t m = 0; m < b_constr.datalen; m++) {
4971                 int8_tArray arr_conv_12 = b_vals[m];
4972                 LDKSignature arr_conv_12_ref;
4973                 CHECK(*((uint32_t*)arr_conv_12) == 64);
4974                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4975                 b_constr.data[m] = arr_conv_12_ref;
4976         }
4977         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4978         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
4979         // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array
4980         // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array[]
4981         return (long)ret_ref;
4982 }
4983
4984 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
4985         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)o;
4986         FREE((void*)o);
4987         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4988         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
4989         return (long)ret_conv;
4990 }
4991
4992 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
4993         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4994         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4995         return (long)ret_conv;
4996 }
4997
4998 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
4999         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)_res;
5000         FREE((void*)_res);
5001         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
5002 }
5003
5004 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
5005         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)orig;
5006         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5007         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
5008         return (long)ret_conv;
5009 }
5010
5011 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
5012         LDKSignature o_ref;
5013         CHECK(*((uint32_t*)o) == 64);
5014         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
5015         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5016         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
5017         return (long)ret_conv;
5018 }
5019
5020 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
5021         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5022         *ret_conv = CResult_SignatureNoneZ_err();
5023         return (long)ret_conv;
5024 }
5025
5026 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
5027         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)_res;
5028         FREE((void*)_res);
5029         CResult_SignatureNoneZ_free(_res_conv);
5030 }
5031
5032 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
5033         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)orig;
5034         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5035         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
5036         return (long)ret_conv;
5037 }
5038
5039 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
5040         LDKCVec_SignatureZ o_constr;
5041         o_constr.datalen = *((uint32_t*)o);
5042         if (o_constr.datalen > 0)
5043                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5044         else
5045                 o_constr.data = NULL;
5046         int8_tArray* o_vals = (int8_tArray*)(o + 4);
5047         for (size_t m = 0; m < o_constr.datalen; m++) {
5048                 int8_tArray arr_conv_12 = o_vals[m];
5049                 LDKSignature arr_conv_12_ref;
5050                 CHECK(*((uint32_t*)arr_conv_12) == 64);
5051                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
5052                 o_constr.data[m] = arr_conv_12_ref;
5053         }
5054         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5055         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
5056         return (long)ret_conv;
5057 }
5058
5059 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
5060         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5061         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
5062         return (long)ret_conv;
5063 }
5064
5065 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5066         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)_res;
5067         FREE((void*)_res);
5068         CResult_CVec_SignatureZNoneZ_free(_res_conv);
5069 }
5070
5071 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
5072         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)orig;
5073         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5074         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
5075         return (long)ret_conv;
5076 }
5077
5078 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_ok(uint32_t o) {
5079         LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
5080         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
5081         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_ok(o_conv);
5082         return (long)ret_conv;
5083 }
5084
5085 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_err(uint32_t e) {
5086         LDKDecodeError e_conv;
5087         e_conv.inner = (void*)(e & (~1));
5088         e_conv.is_owned = (e & 1) || (e == 0);
5089         // Warning: we may need a move here but can't clone!
5090         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
5091         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_err(e_conv);
5092         return (long)ret_conv;
5093 }
5094
5095 void  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_free(uint32_t _res) {
5096         LDKCResult_ChanKeySignerDecodeErrorZ _res_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)_res;
5097         FREE((void*)_res);
5098         CResult_ChanKeySignerDecodeErrorZ_free(_res_conv);
5099 }
5100
5101 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_ok(uint32_t o) {
5102         LDKInMemoryChannelKeys o_conv;
5103         o_conv.inner = (void*)(o & (~1));
5104         o_conv.is_owned = (o & 1) || (o == 0);
5105         if (o_conv.inner != NULL)
5106                 o_conv = InMemoryChannelKeys_clone(&o_conv);
5107         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
5108         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
5109         return (long)ret_conv;
5110 }
5111
5112 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_err(uint32_t e) {
5113         LDKDecodeError e_conv;
5114         e_conv.inner = (void*)(e & (~1));
5115         e_conv.is_owned = (e & 1) || (e == 0);
5116         // Warning: we may need a move here but can't clone!
5117         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
5118         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
5119         return (long)ret_conv;
5120 }
5121
5122 void  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_free(uint32_t _res) {
5123         LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)_res;
5124         FREE((void*)_res);
5125         CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
5126 }
5127
5128 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
5129         LDKTxOut o_conv = *(LDKTxOut*)o;
5130         FREE((void*)o);
5131         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5132         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
5133         return (long)ret_conv;
5134 }
5135
5136 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
5137         LDKAccessError e_conv = LDKAccessError_from_js(e);
5138         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5139         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
5140         return (long)ret_conv;
5141 }
5142
5143 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
5144         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)_res;
5145         FREE((void*)_res);
5146         CResult_TxOutAccessErrorZ_free(_res_conv);
5147 }
5148
5149 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
5150         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5151         *ret_conv = CResult_NoneAPIErrorZ_ok();
5152         return (long)ret_conv;
5153 }
5154
5155 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
5156         LDKAPIError e_conv = *(LDKAPIError*)e;
5157         FREE((void*)e);
5158         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5159         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
5160         return (long)ret_conv;
5161 }
5162
5163 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
5164         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)_res;
5165         FREE((void*)_res);
5166         CResult_NoneAPIErrorZ_free(_res_conv);
5167 }
5168
5169 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
5170         LDKCVec_ChannelDetailsZ _res_constr;
5171         _res_constr.datalen = *((uint32_t*)_res);
5172         if (_res_constr.datalen > 0)
5173                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
5174         else
5175                 _res_constr.data = NULL;
5176         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5177         for (size_t q = 0; q < _res_constr.datalen; q++) {
5178                 uint32_t arr_conv_16 = _res_vals[q];
5179                 LDKChannelDetails arr_conv_16_conv;
5180                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5181                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5182                 _res_constr.data[q] = arr_conv_16_conv;
5183         }
5184         CVec_ChannelDetailsZ_free(_res_constr);
5185 }
5186
5187 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
5188         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5189         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
5190         return (long)ret_conv;
5191 }
5192
5193 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
5194         LDKPaymentSendFailure e_conv;
5195         e_conv.inner = (void*)(e & (~1));
5196         e_conv.is_owned = (e & 1) || (e == 0);
5197         // Warning: we may need a move here but can't clone!
5198         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5199         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
5200         return (long)ret_conv;
5201 }
5202
5203 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
5204         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)_res;
5205         FREE((void*)_res);
5206         CResult_NonePaymentSendFailureZ_free(_res_conv);
5207 }
5208
5209 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
5210         LDKCVec_NetAddressZ _res_constr;
5211         _res_constr.datalen = *((uint32_t*)_res);
5212         if (_res_constr.datalen > 0)
5213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
5214         else
5215                 _res_constr.data = NULL;
5216         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5217         for (size_t m = 0; m < _res_constr.datalen; m++) {
5218                 uint32_t arr_conv_12 = _res_vals[m];
5219                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
5220                 FREE((void*)arr_conv_12);
5221                 _res_constr.data[m] = arr_conv_12_conv;
5222         }
5223         CVec_NetAddressZ_free(_res_constr);
5224 }
5225
5226 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
5227         LDKCVec_ChannelMonitorZ _res_constr;
5228         _res_constr.datalen = *((uint32_t*)_res);
5229         if (_res_constr.datalen > 0)
5230                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
5231         else
5232                 _res_constr.data = NULL;
5233         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5234         for (size_t q = 0; q < _res_constr.datalen; q++) {
5235                 uint32_t arr_conv_16 = _res_vals[q];
5236                 LDKChannelMonitor arr_conv_16_conv;
5237                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5238                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5239                 _res_constr.data[q] = arr_conv_16_conv;
5240         }
5241         CVec_ChannelMonitorZ_free(_res_constr);
5242 }
5243
5244 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
5245         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)_res;
5246         FREE((void*)_res);
5247         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
5248 }
5249
5250 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
5251         LDKThirtyTwoBytes a_ref;
5252         CHECK(*((uint32_t*)a) == 32);
5253         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
5254         LDKChannelManager b_conv;
5255         b_conv.inner = (void*)(b & (~1));
5256         b_conv.is_owned = (b & 1) || (b == 0);
5257         // Warning: we may need a move here but can't clone!
5258         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
5259         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
5260         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
5261         // XXX: We likely need to clone here, but no _clone fn is available for ChannelManager
5262         return (long)ret_ref;
5263 }
5264
5265 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
5266         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)o;
5267         FREE((void*)o);
5268         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5269         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
5270         return (long)ret_conv;
5271 }
5272
5273 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
5274         LDKDecodeError e_conv;
5275         e_conv.inner = (void*)(e & (~1));
5276         e_conv.is_owned = (e & 1) || (e == 0);
5277         // Warning: we may need a move here but can't clone!
5278         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5279         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
5280         return (long)ret_conv;
5281 }
5282
5283 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
5284         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)_res;
5285         FREE((void*)_res);
5286         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
5287 }
5288
5289 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
5290         LDKNetAddress o_conv = *(LDKNetAddress*)o;
5291         FREE((void*)o);
5292         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5293         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
5294         return (long)ret_conv;
5295 }
5296
5297 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
5298         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5299         *ret_conv = CResult_NetAddressu8Z_err(e);
5300         return (long)ret_conv;
5301 }
5302
5303 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
5304         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)_res;
5305         FREE((void*)_res);
5306         CResult_NetAddressu8Z_free(_res_conv);
5307 }
5308
5309 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
5310         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)o;
5311         FREE((void*)o);
5312         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5313         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
5314         return (long)ret_conv;
5315 }
5316
5317 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
5318         LDKDecodeError e_conv;
5319         e_conv.inner = (void*)(e & (~1));
5320         e_conv.is_owned = (e & 1) || (e == 0);
5321         // Warning: we may need a move here but can't clone!
5322         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5323         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
5324         return (long)ret_conv;
5325 }
5326
5327 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
5328         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)_res;
5329         FREE((void*)_res);
5330         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
5331 }
5332
5333 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
5334         LDKCVec_u64Z _res_constr;
5335         _res_constr.datalen = *((uint32_t*)_res);
5336         if (_res_constr.datalen > 0)
5337                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
5338         else
5339                 _res_constr.data = NULL;
5340         int64_t* _res_vals = (int64_t*)(_res + 4);
5341         for (size_t i = 0; i < _res_constr.datalen; i++) {
5342                 int64_t arr_conv_8 = _res_vals[i];
5343                 _res_constr.data[i] = arr_conv_8;
5344         }
5345         CVec_u64Z_free(_res_constr);
5346 }
5347
5348 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
5349         LDKCVec_UpdateAddHTLCZ _res_constr;
5350         _res_constr.datalen = *((uint32_t*)_res);
5351         if (_res_constr.datalen > 0)
5352                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
5353         else
5354                 _res_constr.data = NULL;
5355         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5356         for (size_t p = 0; p < _res_constr.datalen; p++) {
5357                 uint32_t arr_conv_15 = _res_vals[p];
5358                 LDKUpdateAddHTLC arr_conv_15_conv;
5359                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
5360                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
5361                 _res_constr.data[p] = arr_conv_15_conv;
5362         }
5363         CVec_UpdateAddHTLCZ_free(_res_constr);
5364 }
5365
5366 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
5367         LDKCVec_UpdateFulfillHTLCZ _res_constr;
5368         _res_constr.datalen = *((uint32_t*)_res);
5369         if (_res_constr.datalen > 0)
5370                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
5371         else
5372                 _res_constr.data = NULL;
5373         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5374         for (size_t t = 0; t < _res_constr.datalen; t++) {
5375                 uint32_t arr_conv_19 = _res_vals[t];
5376                 LDKUpdateFulfillHTLC arr_conv_19_conv;
5377                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5378                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5379                 _res_constr.data[t] = arr_conv_19_conv;
5380         }
5381         CVec_UpdateFulfillHTLCZ_free(_res_constr);
5382 }
5383
5384 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
5385         LDKCVec_UpdateFailHTLCZ _res_constr;
5386         _res_constr.datalen = *((uint32_t*)_res);
5387         if (_res_constr.datalen > 0)
5388                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
5389         else
5390                 _res_constr.data = NULL;
5391         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5392         for (size_t q = 0; q < _res_constr.datalen; q++) {
5393                 uint32_t arr_conv_16 = _res_vals[q];
5394                 LDKUpdateFailHTLC arr_conv_16_conv;
5395                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5396                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5397                 _res_constr.data[q] = arr_conv_16_conv;
5398         }
5399         CVec_UpdateFailHTLCZ_free(_res_constr);
5400 }
5401
5402 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
5403         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
5404         _res_constr.datalen = *((uint32_t*)_res);
5405         if (_res_constr.datalen > 0)
5406                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
5407         else
5408                 _res_constr.data = NULL;
5409         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5410         for (size_t z = 0; z < _res_constr.datalen; z++) {
5411                 uint32_t arr_conv_25 = _res_vals[z];
5412                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
5413                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
5414                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
5415                 _res_constr.data[z] = arr_conv_25_conv;
5416         }
5417         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
5418 }
5419
5420 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5421         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5422         *ret_conv = CResult_boolLightningErrorZ_ok(o);
5423         return (long)ret_conv;
5424 }
5425
5426 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5427         LDKLightningError e_conv;
5428         e_conv.inner = (void*)(e & (~1));
5429         e_conv.is_owned = (e & 1) || (e == 0);
5430         // Warning: we may need a move here but can't clone!
5431         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5432         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5433         return (long)ret_conv;
5434 }
5435
5436 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5437         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)_res;
5438         FREE((void*)_res);
5439         CResult_boolLightningErrorZ_free(_res_conv);
5440 }
5441
5442 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5443         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)_res;
5444         FREE((void*)_res);
5445         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5446 }
5447
5448 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5449         LDKChannelAnnouncement a_conv;
5450         a_conv.inner = (void*)(a & (~1));
5451         a_conv.is_owned = (a & 1) || (a == 0);
5452         if (a_conv.inner != NULL)
5453                 a_conv = ChannelAnnouncement_clone(&a_conv);
5454         LDKChannelUpdate b_conv;
5455         b_conv.inner = (void*)(b & (~1));
5456         b_conv.is_owned = (b & 1) || (b == 0);
5457         if (b_conv.inner != NULL)
5458                 b_conv = ChannelUpdate_clone(&b_conv);
5459         LDKChannelUpdate c_conv;
5460         c_conv.inner = (void*)(c & (~1));
5461         c_conv.is_owned = (c & 1) || (c == 0);
5462         if (c_conv.inner != NULL)
5463                 c_conv = ChannelUpdate_clone(&c_conv);
5464         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5465         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5466         ret_ref->a = ChannelAnnouncement_clone(&ret_ref->a);
5467         ret_ref->b = ChannelUpdate_clone(&ret_ref->b);
5468         ret_ref->c = ChannelUpdate_clone(&ret_ref->c);
5469         return (long)ret_ref;
5470 }
5471
5472 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5473         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5474         _res_constr.datalen = *((uint32_t*)_res);
5475         if (_res_constr.datalen > 0)
5476                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5477         else
5478                 _res_constr.data = NULL;
5479         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5480         for (size_t l = 0; l < _res_constr.datalen; l++) {
5481                 uint32_t arr_conv_63 = _res_vals[l];
5482                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
5483                 FREE((void*)arr_conv_63);
5484                 _res_constr.data[l] = arr_conv_63_conv;
5485         }
5486         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5487 }
5488
5489 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5490         LDKCVec_NodeAnnouncementZ _res_constr;
5491         _res_constr.datalen = *((uint32_t*)_res);
5492         if (_res_constr.datalen > 0)
5493                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5494         else
5495                 _res_constr.data = NULL;
5496         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5497         for (size_t s = 0; s < _res_constr.datalen; s++) {
5498                 uint32_t arr_conv_18 = _res_vals[s];
5499                 LDKNodeAnnouncement arr_conv_18_conv;
5500                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
5501                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
5502                 _res_constr.data[s] = arr_conv_18_conv;
5503         }
5504         CVec_NodeAnnouncementZ_free(_res_constr);
5505 }
5506
5507 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
5508         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5509         *ret_conv = CResult_NoneLightningErrorZ_ok();
5510         return (long)ret_conv;
5511 }
5512
5513 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
5514         LDKLightningError e_conv;
5515         e_conv.inner = (void*)(e & (~1));
5516         e_conv.is_owned = (e & 1) || (e == 0);
5517         // Warning: we may need a move here but can't clone!
5518         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5519         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
5520         return (long)ret_conv;
5521 }
5522
5523 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
5524         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)_res;
5525         FREE((void*)_res);
5526         CResult_NoneLightningErrorZ_free(_res_conv);
5527 }
5528
5529 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
5530         LDKChannelReestablish o_conv;
5531         o_conv.inner = (void*)(o & (~1));
5532         o_conv.is_owned = (o & 1) || (o == 0);
5533         if (o_conv.inner != NULL)
5534                 o_conv = ChannelReestablish_clone(&o_conv);
5535         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5536         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
5537         return (long)ret_conv;
5538 }
5539
5540 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
5541         LDKDecodeError e_conv;
5542         e_conv.inner = (void*)(e & (~1));
5543         e_conv.is_owned = (e & 1) || (e == 0);
5544         // Warning: we may need a move here but can't clone!
5545         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5546         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
5547         return (long)ret_conv;
5548 }
5549
5550 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
5551         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)_res;
5552         FREE((void*)_res);
5553         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
5554 }
5555
5556 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
5557         LDKInit o_conv;
5558         o_conv.inner = (void*)(o & (~1));
5559         o_conv.is_owned = (o & 1) || (o == 0);
5560         if (o_conv.inner != NULL)
5561                 o_conv = Init_clone(&o_conv);
5562         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5563         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
5564         return (long)ret_conv;
5565 }
5566
5567 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
5568         LDKDecodeError e_conv;
5569         e_conv.inner = (void*)(e & (~1));
5570         e_conv.is_owned = (e & 1) || (e == 0);
5571         // Warning: we may need a move here but can't clone!
5572         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5573         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
5574         return (long)ret_conv;
5575 }
5576
5577 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
5578         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)_res;
5579         FREE((void*)_res);
5580         CResult_InitDecodeErrorZ_free(_res_conv);
5581 }
5582
5583 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
5584         LDKPing o_conv;
5585         o_conv.inner = (void*)(o & (~1));
5586         o_conv.is_owned = (o & 1) || (o == 0);
5587         if (o_conv.inner != NULL)
5588                 o_conv = Ping_clone(&o_conv);
5589         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5590         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
5591         return (long)ret_conv;
5592 }
5593
5594 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
5595         LDKDecodeError e_conv;
5596         e_conv.inner = (void*)(e & (~1));
5597         e_conv.is_owned = (e & 1) || (e == 0);
5598         // Warning: we may need a move here but can't clone!
5599         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5600         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
5601         return (long)ret_conv;
5602 }
5603
5604 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
5605         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)_res;
5606         FREE((void*)_res);
5607         CResult_PingDecodeErrorZ_free(_res_conv);
5608 }
5609
5610 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
5611         LDKPong o_conv;
5612         o_conv.inner = (void*)(o & (~1));
5613         o_conv.is_owned = (o & 1) || (o == 0);
5614         if (o_conv.inner != NULL)
5615                 o_conv = Pong_clone(&o_conv);
5616         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5617         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
5618         return (long)ret_conv;
5619 }
5620
5621 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
5622         LDKDecodeError e_conv;
5623         e_conv.inner = (void*)(e & (~1));
5624         e_conv.is_owned = (e & 1) || (e == 0);
5625         // Warning: we may need a move here but can't clone!
5626         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5627         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
5628         return (long)ret_conv;
5629 }
5630
5631 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
5632         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)_res;
5633         FREE((void*)_res);
5634         CResult_PongDecodeErrorZ_free(_res_conv);
5635 }
5636
5637 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
5638         LDKUnsignedChannelAnnouncement o_conv;
5639         o_conv.inner = (void*)(o & (~1));
5640         o_conv.is_owned = (o & 1) || (o == 0);
5641         if (o_conv.inner != NULL)
5642                 o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
5643         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5644         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
5645         return (long)ret_conv;
5646 }
5647
5648 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
5649         LDKDecodeError e_conv;
5650         e_conv.inner = (void*)(e & (~1));
5651         e_conv.is_owned = (e & 1) || (e == 0);
5652         // Warning: we may need a move here but can't clone!
5653         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5654         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
5655         return (long)ret_conv;
5656 }
5657
5658 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
5659         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)_res;
5660         FREE((void*)_res);
5661         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
5662 }
5663
5664 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
5665         LDKUnsignedChannelUpdate o_conv;
5666         o_conv.inner = (void*)(o & (~1));
5667         o_conv.is_owned = (o & 1) || (o == 0);
5668         if (o_conv.inner != NULL)
5669                 o_conv = UnsignedChannelUpdate_clone(&o_conv);
5670         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5671         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
5672         return (long)ret_conv;
5673 }
5674
5675 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
5676         LDKDecodeError e_conv;
5677         e_conv.inner = (void*)(e & (~1));
5678         e_conv.is_owned = (e & 1) || (e == 0);
5679         // Warning: we may need a move here but can't clone!
5680         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5681         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
5682         return (long)ret_conv;
5683 }
5684
5685 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
5686         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)_res;
5687         FREE((void*)_res);
5688         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
5689 }
5690
5691 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
5692         LDKErrorMessage o_conv;
5693         o_conv.inner = (void*)(o & (~1));
5694         o_conv.is_owned = (o & 1) || (o == 0);
5695         if (o_conv.inner != NULL)
5696                 o_conv = ErrorMessage_clone(&o_conv);
5697         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5698         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
5699         return (long)ret_conv;
5700 }
5701
5702 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
5703         LDKDecodeError e_conv;
5704         e_conv.inner = (void*)(e & (~1));
5705         e_conv.is_owned = (e & 1) || (e == 0);
5706         // Warning: we may need a move here but can't clone!
5707         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5708         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
5709         return (long)ret_conv;
5710 }
5711
5712 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
5713         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)_res;
5714         FREE((void*)_res);
5715         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
5716 }
5717
5718 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
5719         LDKUnsignedNodeAnnouncement o_conv;
5720         o_conv.inner = (void*)(o & (~1));
5721         o_conv.is_owned = (o & 1) || (o == 0);
5722         if (o_conv.inner != NULL)
5723                 o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
5724         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5725         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
5726         return (long)ret_conv;
5727 }
5728
5729 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
5730         LDKDecodeError e_conv;
5731         e_conv.inner = (void*)(e & (~1));
5732         e_conv.is_owned = (e & 1) || (e == 0);
5733         // Warning: we may need a move here but can't clone!
5734         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5735         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
5736         return (long)ret_conv;
5737 }
5738
5739 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
5740         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)_res;
5741         FREE((void*)_res);
5742         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
5743 }
5744
5745 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
5746         LDKQueryShortChannelIds o_conv;
5747         o_conv.inner = (void*)(o & (~1));
5748         o_conv.is_owned = (o & 1) || (o == 0);
5749         if (o_conv.inner != NULL)
5750                 o_conv = QueryShortChannelIds_clone(&o_conv);
5751         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5752         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
5753         return (long)ret_conv;
5754 }
5755
5756 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
5757         LDKDecodeError e_conv;
5758         e_conv.inner = (void*)(e & (~1));
5759         e_conv.is_owned = (e & 1) || (e == 0);
5760         // Warning: we may need a move here but can't clone!
5761         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5762         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
5763         return (long)ret_conv;
5764 }
5765
5766 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
5767         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)_res;
5768         FREE((void*)_res);
5769         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
5770 }
5771
5772 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
5773         LDKReplyShortChannelIdsEnd o_conv;
5774         o_conv.inner = (void*)(o & (~1));
5775         o_conv.is_owned = (o & 1) || (o == 0);
5776         if (o_conv.inner != NULL)
5777                 o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
5778         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5779         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
5780         return (long)ret_conv;
5781 }
5782
5783 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
5784         LDKDecodeError e_conv;
5785         e_conv.inner = (void*)(e & (~1));
5786         e_conv.is_owned = (e & 1) || (e == 0);
5787         // Warning: we may need a move here but can't clone!
5788         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5789         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
5790         return (long)ret_conv;
5791 }
5792
5793 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
5794         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)_res;
5795         FREE((void*)_res);
5796         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
5797 }
5798
5799 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
5800         LDKQueryChannelRange o_conv;
5801         o_conv.inner = (void*)(o & (~1));
5802         o_conv.is_owned = (o & 1) || (o == 0);
5803         if (o_conv.inner != NULL)
5804                 o_conv = QueryChannelRange_clone(&o_conv);
5805         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5806         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
5807         return (long)ret_conv;
5808 }
5809
5810 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
5811         LDKDecodeError e_conv;
5812         e_conv.inner = (void*)(e & (~1));
5813         e_conv.is_owned = (e & 1) || (e == 0);
5814         // Warning: we may need a move here but can't clone!
5815         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5816         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
5817         return (long)ret_conv;
5818 }
5819
5820 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
5821         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)_res;
5822         FREE((void*)_res);
5823         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
5824 }
5825
5826 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
5827         LDKReplyChannelRange o_conv;
5828         o_conv.inner = (void*)(o & (~1));
5829         o_conv.is_owned = (o & 1) || (o == 0);
5830         if (o_conv.inner != NULL)
5831                 o_conv = ReplyChannelRange_clone(&o_conv);
5832         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5833         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
5834         return (long)ret_conv;
5835 }
5836
5837 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
5838         LDKDecodeError e_conv;
5839         e_conv.inner = (void*)(e & (~1));
5840         e_conv.is_owned = (e & 1) || (e == 0);
5841         // Warning: we may need a move here but can't clone!
5842         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5843         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
5844         return (long)ret_conv;
5845 }
5846
5847 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
5848         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)_res;
5849         FREE((void*)_res);
5850         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
5851 }
5852
5853 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
5854         LDKGossipTimestampFilter o_conv;
5855         o_conv.inner = (void*)(o & (~1));
5856         o_conv.is_owned = (o & 1) || (o == 0);
5857         if (o_conv.inner != NULL)
5858                 o_conv = GossipTimestampFilter_clone(&o_conv);
5859         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5860         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
5861         return (long)ret_conv;
5862 }
5863
5864 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
5865         LDKDecodeError e_conv;
5866         e_conv.inner = (void*)(e & (~1));
5867         e_conv.is_owned = (e & 1) || (e == 0);
5868         // Warning: we may need a move here but can't clone!
5869         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5870         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
5871         return (long)ret_conv;
5872 }
5873
5874 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
5875         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)_res;
5876         FREE((void*)_res);
5877         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
5878 }
5879
5880 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
5881         LDKCVec_PublicKeyZ _res_constr;
5882         _res_constr.datalen = *((uint32_t*)_res);
5883         if (_res_constr.datalen > 0)
5884                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
5885         else
5886                 _res_constr.data = NULL;
5887         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5888         for (size_t m = 0; m < _res_constr.datalen; m++) {
5889                 int8_tArray arr_conv_12 = _res_vals[m];
5890                 LDKPublicKey arr_conv_12_ref;
5891                 CHECK(*((uint32_t*)arr_conv_12) == 33);
5892                 memcpy(arr_conv_12_ref.compressed_form, (uint8_t*)(arr_conv_12 + 4), 33);
5893                 _res_constr.data[m] = arr_conv_12_ref;
5894         }
5895         CVec_PublicKeyZ_free(_res_constr);
5896 }
5897
5898 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
5899         LDKCVec_u8Z _res_ref;
5900         _res_ref.datalen = *((uint32_t*)_res);
5901         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
5902         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5903         CVec_u8Z_free(_res_ref);
5904 }
5905
5906 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
5907         LDKCVec_u8Z o_ref;
5908         o_ref.datalen = *((uint32_t*)o);
5909         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
5910         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
5911         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5912         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
5913         return (long)ret_conv;
5914 }
5915
5916 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
5917         LDKPeerHandleError e_conv;
5918         e_conv.inner = (void*)(e & (~1));
5919         e_conv.is_owned = (e & 1) || (e == 0);
5920         // Warning: we may need a move here but can't clone!
5921         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5922         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
5923         return (long)ret_conv;
5924 }
5925
5926 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
5927         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)_res;
5928         FREE((void*)_res);
5929         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
5930 }
5931
5932 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
5933         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5934         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
5935         return (long)ret_conv;
5936 }
5937
5938 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
5939         LDKPeerHandleError e_conv;
5940         e_conv.inner = (void*)(e & (~1));
5941         e_conv.is_owned = (e & 1) || (e == 0);
5942         // Warning: we may need a move here but can't clone!
5943         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5944         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
5945         return (long)ret_conv;
5946 }
5947
5948 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
5949         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)_res;
5950         FREE((void*)_res);
5951         CResult_NonePeerHandleErrorZ_free(_res_conv);
5952 }
5953
5954 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
5955         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5956         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
5957         return (long)ret_conv;
5958 }
5959
5960 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
5961         LDKPeerHandleError e_conv;
5962         e_conv.inner = (void*)(e & (~1));
5963         e_conv.is_owned = (e & 1) || (e == 0);
5964         // Warning: we may need a move here but can't clone!
5965         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5966         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
5967         return (long)ret_conv;
5968 }
5969
5970 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
5971         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)_res;
5972         FREE((void*)_res);
5973         CResult_boolPeerHandleErrorZ_free(_res_conv);
5974 }
5975
5976 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_ok(int8_tArray o) {
5977         LDKSecretKey o_ref;
5978         CHECK(*((uint32_t*)o) == 32);
5979         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5980         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5981         *ret_conv = CResult_SecretKeySecpErrorZ_ok(o_ref);
5982         return (long)ret_conv;
5983 }
5984
5985 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_err(uint32_t e) {
5986         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5987         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5988         *ret_conv = CResult_SecretKeySecpErrorZ_err(e_conv);
5989         return (long)ret_conv;
5990 }
5991
5992 void  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_free(uint32_t _res) {
5993         LDKCResult_SecretKeySecpErrorZ _res_conv = *(LDKCResult_SecretKeySecpErrorZ*)_res;
5994         FREE((void*)_res);
5995         CResult_SecretKeySecpErrorZ_free(_res_conv);
5996 }
5997
5998 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_ok(int8_tArray o) {
5999         LDKPublicKey o_ref;
6000         CHECK(*((uint32_t*)o) == 33);
6001         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
6002         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
6003         *ret_conv = CResult_PublicKeySecpErrorZ_ok(o_ref);
6004         return (long)ret_conv;
6005 }
6006
6007 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_err(uint32_t e) {
6008         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6009         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
6010         *ret_conv = CResult_PublicKeySecpErrorZ_err(e_conv);
6011         return (long)ret_conv;
6012 }
6013
6014 void  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_free(uint32_t _res) {
6015         LDKCResult_PublicKeySecpErrorZ _res_conv = *(LDKCResult_PublicKeySecpErrorZ*)_res;
6016         FREE((void*)_res);
6017         CResult_PublicKeySecpErrorZ_free(_res_conv);
6018 }
6019
6020 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_ok(uint32_t o) {
6021         LDKTxCreationKeys o_conv;
6022         o_conv.inner = (void*)(o & (~1));
6023         o_conv.is_owned = (o & 1) || (o == 0);
6024         if (o_conv.inner != NULL)
6025                 o_conv = TxCreationKeys_clone(&o_conv);
6026         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
6027         *ret_conv = CResult_TxCreationKeysSecpErrorZ_ok(o_conv);
6028         return (long)ret_conv;
6029 }
6030
6031 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_err(uint32_t e) {
6032         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
6033         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
6034         *ret_conv = CResult_TxCreationKeysSecpErrorZ_err(e_conv);
6035         return (long)ret_conv;
6036 }
6037
6038 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_free(uint32_t _res) {
6039         LDKCResult_TxCreationKeysSecpErrorZ _res_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)_res;
6040         FREE((void*)_res);
6041         CResult_TxCreationKeysSecpErrorZ_free(_res_conv);
6042 }
6043
6044 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
6045         LDKTrustedCommitmentTransaction o_conv;
6046         o_conv.inner = (void*)(o & (~1));
6047         o_conv.is_owned = (o & 1) || (o == 0);
6048         // Warning: we may need a move here but can't clone!
6049         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6050         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
6051         return (long)ret_conv;
6052 }
6053
6054 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
6055         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
6056         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
6057         return (long)ret_conv;
6058 }
6059
6060 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
6061         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)_res;
6062         FREE((void*)_res);
6063         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
6064 }
6065
6066 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
6067         LDKCVec_RouteHopZ _res_constr;
6068         _res_constr.datalen = *((uint32_t*)_res);
6069         if (_res_constr.datalen > 0)
6070                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6071         else
6072                 _res_constr.data = NULL;
6073         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6074         for (size_t k = 0; k < _res_constr.datalen; k++) {
6075                 uint32_t arr_conv_10 = _res_vals[k];
6076                 LDKRouteHop arr_conv_10_conv;
6077                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
6078                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
6079                 _res_constr.data[k] = arr_conv_10_conv;
6080         }
6081         CVec_RouteHopZ_free(_res_constr);
6082 }
6083
6084 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
6085         LDKCVec_CVec_RouteHopZZ _res_constr;
6086         _res_constr.datalen = *((uint32_t*)_res);
6087         if (_res_constr.datalen > 0)
6088                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
6089         else
6090                 _res_constr.data = NULL;
6091         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
6092         for (size_t m = 0; m < _res_constr.datalen; m++) {
6093                 uint32_tArray arr_conv_12 = _res_vals[m];
6094                 LDKCVec_RouteHopZ arr_conv_12_constr;
6095                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
6096                 if (arr_conv_12_constr.datalen > 0)
6097                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6098                 else
6099                         arr_conv_12_constr.data = NULL;
6100                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
6101                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
6102                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
6103                         LDKRouteHop arr_conv_10_conv;
6104                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
6105                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
6106                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
6107                 }
6108                 _res_constr.data[m] = arr_conv_12_constr;
6109         }
6110         CVec_CVec_RouteHopZZ_free(_res_constr);
6111 }
6112
6113 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
6114         LDKRoute o_conv;
6115         o_conv.inner = (void*)(o & (~1));
6116         o_conv.is_owned = (o & 1) || (o == 0);
6117         if (o_conv.inner != NULL)
6118                 o_conv = Route_clone(&o_conv);
6119         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6120         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
6121         return (long)ret_conv;
6122 }
6123
6124 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
6125         LDKDecodeError e_conv;
6126         e_conv.inner = (void*)(e & (~1));
6127         e_conv.is_owned = (e & 1) || (e == 0);
6128         // Warning: we may need a move here but can't clone!
6129         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6130         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
6131         return (long)ret_conv;
6132 }
6133
6134 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
6135         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)_res;
6136         FREE((void*)_res);
6137         CResult_RouteDecodeErrorZ_free(_res_conv);
6138 }
6139
6140 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
6141         LDKCVec_RouteHintZ _res_constr;
6142         _res_constr.datalen = *((uint32_t*)_res);
6143         if (_res_constr.datalen > 0)
6144                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
6145         else
6146                 _res_constr.data = NULL;
6147         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6148         for (size_t l = 0; l < _res_constr.datalen; l++) {
6149                 uint32_t arr_conv_11 = _res_vals[l];
6150                 LDKRouteHint arr_conv_11_conv;
6151                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
6152                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
6153                 _res_constr.data[l] = arr_conv_11_conv;
6154         }
6155         CVec_RouteHintZ_free(_res_constr);
6156 }
6157
6158 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
6159         LDKRoute o_conv;
6160         o_conv.inner = (void*)(o & (~1));
6161         o_conv.is_owned = (o & 1) || (o == 0);
6162         if (o_conv.inner != NULL)
6163                 o_conv = Route_clone(&o_conv);
6164         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6165         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
6166         return (long)ret_conv;
6167 }
6168
6169 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
6170         LDKLightningError e_conv;
6171         e_conv.inner = (void*)(e & (~1));
6172         e_conv.is_owned = (e & 1) || (e == 0);
6173         // Warning: we may need a move here but can't clone!
6174         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6175         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
6176         return (long)ret_conv;
6177 }
6178
6179 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
6180         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)_res;
6181         FREE((void*)_res);
6182         CResult_RouteLightningErrorZ_free(_res_conv);
6183 }
6184
6185 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6186         LDKRoutingFees o_conv;
6187         o_conv.inner = (void*)(o & (~1));
6188         o_conv.is_owned = (o & 1) || (o == 0);
6189         if (o_conv.inner != NULL)
6190                 o_conv = RoutingFees_clone(&o_conv);
6191         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6192         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6193         return (long)ret_conv;
6194 }
6195
6196 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6197         LDKDecodeError e_conv;
6198         e_conv.inner = (void*)(e & (~1));
6199         e_conv.is_owned = (e & 1) || (e == 0);
6200         // Warning: we may need a move here but can't clone!
6201         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6202         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6203         return (long)ret_conv;
6204 }
6205
6206 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6207         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)_res;
6208         FREE((void*)_res);
6209         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6210 }
6211
6212 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6213         LDKNodeAnnouncementInfo o_conv;
6214         o_conv.inner = (void*)(o & (~1));
6215         o_conv.is_owned = (o & 1) || (o == 0);
6216         // Warning: we may need a move here but can't clone!
6217         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6218         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6219         return (long)ret_conv;
6220 }
6221
6222 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6223         LDKDecodeError e_conv;
6224         e_conv.inner = (void*)(e & (~1));
6225         e_conv.is_owned = (e & 1) || (e == 0);
6226         // Warning: we may need a move here but can't clone!
6227         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6228         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6229         return (long)ret_conv;
6230 }
6231
6232 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6233         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)_res;
6234         FREE((void*)_res);
6235         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6236 }
6237
6238 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6239         LDKNodeInfo o_conv;
6240         o_conv.inner = (void*)(o & (~1));
6241         o_conv.is_owned = (o & 1) || (o == 0);
6242         // Warning: we may need a move here but can't clone!
6243         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6244         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6245         return (long)ret_conv;
6246 }
6247
6248 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6249         LDKDecodeError e_conv;
6250         e_conv.inner = (void*)(e & (~1));
6251         e_conv.is_owned = (e & 1) || (e == 0);
6252         // Warning: we may need a move here but can't clone!
6253         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6254         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6255         return (long)ret_conv;
6256 }
6257
6258 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6259         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)_res;
6260         FREE((void*)_res);
6261         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6262 }
6263
6264 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6265         LDKNetworkGraph o_conv;
6266         o_conv.inner = (void*)(o & (~1));
6267         o_conv.is_owned = (o & 1) || (o == 0);
6268         // Warning: we may need a move here but can't clone!
6269         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6270         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6271         return (long)ret_conv;
6272 }
6273
6274 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6275         LDKDecodeError e_conv;
6276         e_conv.inner = (void*)(e & (~1));
6277         e_conv.is_owned = (e & 1) || (e == 0);
6278         // Warning: we may need a move here but can't clone!
6279         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6280         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6281         return (long)ret_conv;
6282 }
6283
6284 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6285         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)_res;
6286         FREE((void*)_res);
6287         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6288 }
6289
6290 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
6291         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
6292         FREE((void*)this_ptr);
6293         Event_free(this_ptr_conv);
6294 }
6295
6296 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
6297         LDKEvent* orig_conv = (LDKEvent*)orig;
6298         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6299         *ret_copy = Event_clone(orig_conv);
6300         long ret_ref = (long)ret_copy;
6301         return ret_ref;
6302 }
6303
6304 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
6305         LDKEvent* obj_conv = (LDKEvent*)obj;
6306         LDKCVec_u8Z arg_var = Event_write(obj_conv);
6307         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6308         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6309         CVec_u8Z_free(arg_var);
6310         return arg_arr;
6311 }
6312
6313 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
6314         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
6315         FREE((void*)this_ptr);
6316         MessageSendEvent_free(this_ptr_conv);
6317 }
6318
6319 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
6320         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
6321         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6322         *ret_copy = MessageSendEvent_clone(orig_conv);
6323         long ret_ref = (long)ret_copy;
6324         return ret_ref;
6325 }
6326
6327 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
6328         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
6329         FREE((void*)this_ptr);
6330         MessageSendEventsProvider_free(this_ptr_conv);
6331 }
6332
6333 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
6334         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
6335         FREE((void*)this_ptr);
6336         EventsProvider_free(this_ptr_conv);
6337 }
6338
6339 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
6340         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
6341         FREE((void*)this_ptr);
6342         APIError_free(this_ptr_conv);
6343 }
6344
6345 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
6346         LDKAPIError* orig_conv = (LDKAPIError*)orig;
6347         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6348         *ret_copy = APIError_clone(orig_conv);
6349         long ret_ref = (long)ret_copy;
6350         return ret_ref;
6351 }
6352
6353 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
6354         LDKLevel* orig_conv = (LDKLevel*)orig;
6355         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
6356         return ret_conv;
6357 }
6358
6359 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
6360         uint32_t ret_conv = LDKLevel_to_js(Level_max());
6361         return ret_conv;
6362 }
6363
6364 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
6365         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
6366         FREE((void*)this_ptr);
6367         Logger_free(this_ptr_conv);
6368 }
6369
6370 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_ptr) {
6371         LDKChannelHandshakeConfig this_ptr_conv;
6372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6373         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6374         ChannelHandshakeConfig_free(this_ptr_conv);
6375 }
6376
6377 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
6378         LDKChannelHandshakeConfig orig_conv;
6379         orig_conv.inner = (void*)(orig & (~1));
6380         orig_conv.is_owned = false;
6381         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
6382         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6383         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6384         long ret_ref = (long)ret_var.inner;
6385         if (ret_var.is_owned) {
6386                 ret_ref |= 1;
6387         }
6388         return ret_ref;
6389 }
6390
6391 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
6392         LDKChannelHandshakeConfig this_ptr_conv;
6393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6394         this_ptr_conv.is_owned = false;
6395         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
6396         return ret_val;
6397 }
6398
6399 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
6400         LDKChannelHandshakeConfig this_ptr_conv;
6401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6402         this_ptr_conv.is_owned = false;
6403         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
6404 }
6405
6406 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
6407         LDKChannelHandshakeConfig this_ptr_conv;
6408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6409         this_ptr_conv.is_owned = false;
6410         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
6411         return ret_val;
6412 }
6413
6414 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
6415         LDKChannelHandshakeConfig this_ptr_conv;
6416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6417         this_ptr_conv.is_owned = false;
6418         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
6419 }
6420
6421 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
6422         LDKChannelHandshakeConfig this_ptr_conv;
6423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6424         this_ptr_conv.is_owned = false;
6425         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
6426         return ret_val;
6427 }
6428
6429 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6430         LDKChannelHandshakeConfig this_ptr_conv;
6431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6432         this_ptr_conv.is_owned = false;
6433         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
6434 }
6435
6436 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) {
6437         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
6438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6440         long ret_ref = (long)ret_var.inner;
6441         if (ret_var.is_owned) {
6442                 ret_ref |= 1;
6443         }
6444         return ret_ref;
6445 }
6446
6447 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
6448         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
6449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6451         long ret_ref = (long)ret_var.inner;
6452         if (ret_var.is_owned) {
6453                 ret_ref |= 1;
6454         }
6455         return ret_ref;
6456 }
6457
6458 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_ptr) {
6459         LDKChannelHandshakeLimits this_ptr_conv;
6460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6461         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6462         ChannelHandshakeLimits_free(this_ptr_conv);
6463 }
6464
6465 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
6466         LDKChannelHandshakeLimits orig_conv;
6467         orig_conv.inner = (void*)(orig & (~1));
6468         orig_conv.is_owned = false;
6469         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
6470         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6471         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6472         long ret_ref = (long)ret_var.inner;
6473         if (ret_var.is_owned) {
6474                 ret_ref |= 1;
6475         }
6476         return ret_ref;
6477 }
6478
6479 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
6480         LDKChannelHandshakeLimits this_ptr_conv;
6481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6482         this_ptr_conv.is_owned = false;
6483         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
6484         return ret_val;
6485 }
6486
6487 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
6488         LDKChannelHandshakeLimits this_ptr_conv;
6489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6490         this_ptr_conv.is_owned = false;
6491         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
6492 }
6493
6494 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
6495         LDKChannelHandshakeLimits this_ptr_conv;
6496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6497         this_ptr_conv.is_owned = false;
6498         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
6499         return ret_val;
6500 }
6501
6502 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6503         LDKChannelHandshakeLimits this_ptr_conv;
6504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6505         this_ptr_conv.is_owned = false;
6506         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
6507 }
6508
6509 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
6510         LDKChannelHandshakeLimits this_ptr_conv;
6511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6512         this_ptr_conv.is_owned = false;
6513         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
6514         return ret_val;
6515 }
6516
6517 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
6518         LDKChannelHandshakeLimits this_ptr_conv;
6519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6520         this_ptr_conv.is_owned = false;
6521         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6522 }
6523
6524 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
6525         LDKChannelHandshakeLimits this_ptr_conv;
6526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6527         this_ptr_conv.is_owned = false;
6528         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
6529         return ret_val;
6530 }
6531
6532 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
6533         LDKChannelHandshakeLimits this_ptr_conv;
6534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6535         this_ptr_conv.is_owned = false;
6536         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
6537 }
6538
6539 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
6540         LDKChannelHandshakeLimits this_ptr_conv;
6541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6542         this_ptr_conv.is_owned = false;
6543         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
6544         return ret_val;
6545 }
6546
6547 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
6548         LDKChannelHandshakeLimits this_ptr_conv;
6549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6550         this_ptr_conv.is_owned = false;
6551         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
6552 }
6553
6554 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
6555         LDKChannelHandshakeLimits this_ptr_conv;
6556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6557         this_ptr_conv.is_owned = false;
6558         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
6559         return ret_val;
6560 }
6561
6562 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6563         LDKChannelHandshakeLimits this_ptr_conv;
6564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6565         this_ptr_conv.is_owned = false;
6566         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
6567 }
6568
6569 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
6570         LDKChannelHandshakeLimits this_ptr_conv;
6571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6572         this_ptr_conv.is_owned = false;
6573         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
6574         return ret_val;
6575 }
6576
6577 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6578         LDKChannelHandshakeLimits this_ptr_conv;
6579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6580         this_ptr_conv.is_owned = false;
6581         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
6582 }
6583
6584 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
6585         LDKChannelHandshakeLimits this_ptr_conv;
6586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6587         this_ptr_conv.is_owned = false;
6588         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
6589         return ret_val;
6590 }
6591
6592 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
6593         LDKChannelHandshakeLimits this_ptr_conv;
6594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6595         this_ptr_conv.is_owned = false;
6596         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
6597 }
6598
6599 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
6600         LDKChannelHandshakeLimits this_ptr_conv;
6601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6602         this_ptr_conv.is_owned = false;
6603         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
6604         return ret_val;
6605 }
6606
6607 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
6608         LDKChannelHandshakeLimits this_ptr_conv;
6609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6610         this_ptr_conv.is_owned = false;
6611         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
6612 }
6613
6614 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
6615         LDKChannelHandshakeLimits this_ptr_conv;
6616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6617         this_ptr_conv.is_owned = false;
6618         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
6619         return ret_val;
6620 }
6621
6622 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
6623         LDKChannelHandshakeLimits this_ptr_conv;
6624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6625         this_ptr_conv.is_owned = false;
6626         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
6627 }
6628
6629 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) {
6630         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);
6631         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6632         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6633         long ret_ref = (long)ret_var.inner;
6634         if (ret_var.is_owned) {
6635                 ret_ref |= 1;
6636         }
6637         return ret_ref;
6638 }
6639
6640 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
6641         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
6642         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6643         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6644         long ret_ref = (long)ret_var.inner;
6645         if (ret_var.is_owned) {
6646                 ret_ref |= 1;
6647         }
6648         return ret_ref;
6649 }
6650
6651 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_ptr) {
6652         LDKChannelConfig this_ptr_conv;
6653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6654         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6655         ChannelConfig_free(this_ptr_conv);
6656 }
6657
6658 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
6659         LDKChannelConfig orig_conv;
6660         orig_conv.inner = (void*)(orig & (~1));
6661         orig_conv.is_owned = false;
6662         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
6663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6665         long ret_ref = (long)ret_var.inner;
6666         if (ret_var.is_owned) {
6667                 ret_ref |= 1;
6668         }
6669         return ret_ref;
6670 }
6671
6672 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
6673         LDKChannelConfig this_ptr_conv;
6674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6675         this_ptr_conv.is_owned = false;
6676         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
6677         return ret_val;
6678 }
6679
6680 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
6681         LDKChannelConfig this_ptr_conv;
6682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6683         this_ptr_conv.is_owned = false;
6684         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
6685 }
6686
6687 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
6688         LDKChannelConfig this_ptr_conv;
6689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6690         this_ptr_conv.is_owned = false;
6691         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
6692         return ret_val;
6693 }
6694
6695 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
6696         LDKChannelConfig this_ptr_conv;
6697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6698         this_ptr_conv.is_owned = false;
6699         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
6700 }
6701
6702 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
6703         LDKChannelConfig this_ptr_conv;
6704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6705         this_ptr_conv.is_owned = false;
6706         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
6707         return ret_val;
6708 }
6709
6710 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
6711         LDKChannelConfig this_ptr_conv;
6712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6713         this_ptr_conv.is_owned = false;
6714         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
6715 }
6716
6717 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
6718         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
6719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6721         long ret_ref = (long)ret_var.inner;
6722         if (ret_var.is_owned) {
6723                 ret_ref |= 1;
6724         }
6725         return ret_ref;
6726 }
6727
6728 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
6729         LDKChannelConfig ret_var = ChannelConfig_default();
6730         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6731         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6732         long ret_ref = (long)ret_var.inner;
6733         if (ret_var.is_owned) {
6734                 ret_ref |= 1;
6735         }
6736         return ret_ref;
6737 }
6738
6739 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
6740         LDKChannelConfig obj_conv;
6741         obj_conv.inner = (void*)(obj & (~1));
6742         obj_conv.is_owned = false;
6743         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
6744         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6745         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6746         CVec_u8Z_free(arg_var);
6747         return arg_arr;
6748 }
6749
6750 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
6751         LDKu8slice ser_ref;
6752         ser_ref.datalen = *((uint32_t*)ser);
6753         ser_ref.data = (int8_t*)(ser + 4);
6754         LDKChannelConfig ret_var = ChannelConfig_read(ser_ref);
6755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6757         long ret_ref = (long)ret_var.inner;
6758         if (ret_var.is_owned) {
6759                 ret_ref |= 1;
6760         }
6761         return ret_ref;
6762 }
6763
6764 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_ptr) {
6765         LDKUserConfig this_ptr_conv;
6766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6767         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6768         UserConfig_free(this_ptr_conv);
6769 }
6770
6771 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
6772         LDKUserConfig orig_conv;
6773         orig_conv.inner = (void*)(orig & (~1));
6774         orig_conv.is_owned = false;
6775         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
6776         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6777         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6778         long ret_ref = (long)ret_var.inner;
6779         if (ret_var.is_owned) {
6780                 ret_ref |= 1;
6781         }
6782         return ret_ref;
6783 }
6784
6785 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
6786         LDKUserConfig this_ptr_conv;
6787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6788         this_ptr_conv.is_owned = false;
6789         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
6790         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6791         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6792         long ret_ref = (long)ret_var.inner;
6793         if (ret_var.is_owned) {
6794                 ret_ref |= 1;
6795         }
6796         return ret_ref;
6797 }
6798
6799 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
6800         LDKUserConfig this_ptr_conv;
6801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6802         this_ptr_conv.is_owned = false;
6803         LDKChannelHandshakeConfig val_conv;
6804         val_conv.inner = (void*)(val & (~1));
6805         val_conv.is_owned = (val & 1) || (val == 0);
6806         if (val_conv.inner != NULL)
6807                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
6808         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
6809 }
6810
6811 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
6812         LDKUserConfig this_ptr_conv;
6813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6814         this_ptr_conv.is_owned = false;
6815         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
6816         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6817         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6818         long ret_ref = (long)ret_var.inner;
6819         if (ret_var.is_owned) {
6820                 ret_ref |= 1;
6821         }
6822         return ret_ref;
6823 }
6824
6825 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
6826         LDKUserConfig this_ptr_conv;
6827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6828         this_ptr_conv.is_owned = false;
6829         LDKChannelHandshakeLimits val_conv;
6830         val_conv.inner = (void*)(val & (~1));
6831         val_conv.is_owned = (val & 1) || (val == 0);
6832         if (val_conv.inner != NULL)
6833                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
6834         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
6835 }
6836
6837 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
6838         LDKUserConfig this_ptr_conv;
6839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6840         this_ptr_conv.is_owned = false;
6841         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
6842         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6843         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6844         long ret_ref = (long)ret_var.inner;
6845         if (ret_var.is_owned) {
6846                 ret_ref |= 1;
6847         }
6848         return ret_ref;
6849 }
6850
6851 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
6852         LDKUserConfig this_ptr_conv;
6853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6854         this_ptr_conv.is_owned = false;
6855         LDKChannelConfig val_conv;
6856         val_conv.inner = (void*)(val & (~1));
6857         val_conv.is_owned = (val & 1) || (val == 0);
6858         if (val_conv.inner != NULL)
6859                 val_conv = ChannelConfig_clone(&val_conv);
6860         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
6861 }
6862
6863 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) {
6864         LDKChannelHandshakeConfig own_channel_config_arg_conv;
6865         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
6866         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
6867         if (own_channel_config_arg_conv.inner != NULL)
6868                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
6869         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
6870         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
6871         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
6872         if (peer_channel_config_limits_arg_conv.inner != NULL)
6873                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
6874         LDKChannelConfig channel_options_arg_conv;
6875         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
6876         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
6877         if (channel_options_arg_conv.inner != NULL)
6878                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
6879         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
6880         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6881         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6882         long ret_ref = (long)ret_var.inner;
6883         if (ret_var.is_owned) {
6884                 ret_ref |= 1;
6885         }
6886         return ret_ref;
6887 }
6888
6889 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
6890         LDKUserConfig ret_var = UserConfig_default();
6891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6893         long ret_ref = (long)ret_var.inner;
6894         if (ret_var.is_owned) {
6895                 ret_ref |= 1;
6896         }
6897         return ret_ref;
6898 }
6899
6900 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
6901         LDKAccessError* orig_conv = (LDKAccessError*)orig;
6902         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
6903         return ret_conv;
6904 }
6905
6906 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
6907         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
6908         FREE((void*)this_ptr);
6909         Access_free(this_ptr_conv);
6910 }
6911
6912 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
6913         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
6914         FREE((void*)this_ptr);
6915         Watch_free(this_ptr_conv);
6916 }
6917
6918 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
6919         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
6920         FREE((void*)this_ptr);
6921         Filter_free(this_ptr_conv);
6922 }
6923
6924 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
6925         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
6926         FREE((void*)this_ptr);
6927         BroadcasterInterface_free(this_ptr_conv);
6928 }
6929
6930 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
6931         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
6932         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
6933         return ret_conv;
6934 }
6935
6936 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
6937         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
6938         FREE((void*)this_ptr);
6939         FeeEstimator_free(this_ptr_conv);
6940 }
6941
6942 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_ptr) {
6943         LDKChainMonitor this_ptr_conv;
6944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6945         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6946         ChainMonitor_free(this_ptr_conv);
6947 }
6948
6949 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
6950         LDKChainMonitor this_arg_conv;
6951         this_arg_conv.inner = (void*)(this_arg & (~1));
6952         this_arg_conv.is_owned = false;
6953         unsigned char header_arr[80];
6954         CHECK(*((uint32_t*)header) == 80);
6955         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6956         unsigned char (*header_ref)[80] = &header_arr;
6957         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6958         txdata_constr.datalen = *((uint32_t*)txdata);
6959         if (txdata_constr.datalen > 0)
6960                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6961         else
6962                 txdata_constr.data = NULL;
6963         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
6964         for (size_t e = 0; e < txdata_constr.datalen; e++) {
6965                 uint32_t arr_conv_30 = txdata_vals[e];
6966                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
6967                 FREE((void*)arr_conv_30);
6968                 txdata_constr.data[e] = arr_conv_30_conv;
6969         }
6970         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6971 }
6972
6973 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
6974         LDKChainMonitor this_arg_conv;
6975         this_arg_conv.inner = (void*)(this_arg & (~1));
6976         this_arg_conv.is_owned = false;
6977         unsigned char header_arr[80];
6978         CHECK(*((uint32_t*)header) == 80);
6979         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6980         unsigned char (*header_ref)[80] = &header_arr;
6981         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
6982 }
6983
6984 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
6985         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
6986         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6987         LDKLogger logger_conv = *(LDKLogger*)logger;
6988         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
6989         LDKPersist persister_conv = *(LDKPersist*)persister;
6990         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
6991         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6992         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6993         long ret_ref = (long)ret_var.inner;
6994         if (ret_var.is_owned) {
6995                 ret_ref |= 1;
6996         }
6997         return ret_ref;
6998 }
6999
7000 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
7001         LDKChainMonitor this_arg_conv;
7002         this_arg_conv.inner = (void*)(this_arg & (~1));
7003         this_arg_conv.is_owned = false;
7004         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
7005         *ret = ChainMonitor_as_Watch(&this_arg_conv);
7006         return (long)ret;
7007 }
7008
7009 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
7010         LDKChainMonitor this_arg_conv;
7011         this_arg_conv.inner = (void*)(this_arg & (~1));
7012         this_arg_conv.is_owned = false;
7013         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7014         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
7015         return (long)ret;
7016 }
7017
7018 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_ptr) {
7019         LDKChannelMonitorUpdate this_ptr_conv;
7020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7021         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7022         ChannelMonitorUpdate_free(this_ptr_conv);
7023 }
7024
7025 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
7026         LDKChannelMonitorUpdate orig_conv;
7027         orig_conv.inner = (void*)(orig & (~1));
7028         orig_conv.is_owned = false;
7029         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
7030         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7031         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7032         long ret_ref = (long)ret_var.inner;
7033         if (ret_var.is_owned) {
7034                 ret_ref |= 1;
7035         }
7036         return ret_ref;
7037 }
7038
7039 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
7040         LDKChannelMonitorUpdate this_ptr_conv;
7041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7042         this_ptr_conv.is_owned = false;
7043         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
7044         return ret_val;
7045 }
7046
7047 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
7048         LDKChannelMonitorUpdate this_ptr_conv;
7049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7050         this_ptr_conv.is_owned = false;
7051         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
7052 }
7053
7054 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
7055         LDKChannelMonitorUpdate obj_conv;
7056         obj_conv.inner = (void*)(obj & (~1));
7057         obj_conv.is_owned = false;
7058         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
7059         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7060         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7061         CVec_u8Z_free(arg_var);
7062         return arg_arr;
7063 }
7064
7065 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
7066         LDKu8slice ser_ref;
7067         ser_ref.datalen = *((uint32_t*)ser);
7068         ser_ref.data = (int8_t*)(ser + 4);
7069         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
7070         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
7071         return (long)ret_conv;
7072 }
7073
7074 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
7075         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
7076         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
7077         return ret_conv;
7078 }
7079
7080 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_ptr) {
7081         LDKMonitorUpdateError this_ptr_conv;
7082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7083         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7084         MonitorUpdateError_free(this_ptr_conv);
7085 }
7086
7087 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
7088         LDKMonitorEvent this_ptr_conv;
7089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7090         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7091         MonitorEvent_free(this_ptr_conv);
7092 }
7093
7094 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
7095         LDKMonitorEvent orig_conv;
7096         orig_conv.inner = (void*)(orig & (~1));
7097         orig_conv.is_owned = false;
7098         LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
7099         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7100         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7101         long ret_ref = (long)ret_var.inner;
7102         if (ret_var.is_owned) {
7103                 ret_ref |= 1;
7104         }
7105         return ret_ref;
7106 }
7107
7108 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_ptr) {
7109         LDKHTLCUpdate this_ptr_conv;
7110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7111         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7112         HTLCUpdate_free(this_ptr_conv);
7113 }
7114
7115 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
7116         LDKHTLCUpdate orig_conv;
7117         orig_conv.inner = (void*)(orig & (~1));
7118         orig_conv.is_owned = false;
7119         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
7120         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7121         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7122         long ret_ref = (long)ret_var.inner;
7123         if (ret_var.is_owned) {
7124                 ret_ref |= 1;
7125         }
7126         return ret_ref;
7127 }
7128
7129 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
7130         LDKHTLCUpdate obj_conv;
7131         obj_conv.inner = (void*)(obj & (~1));
7132         obj_conv.is_owned = false;
7133         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
7134         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7135         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7136         CVec_u8Z_free(arg_var);
7137         return arg_arr;
7138 }
7139
7140 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
7141         LDKu8slice ser_ref;
7142         ser_ref.datalen = *((uint32_t*)ser);
7143         ser_ref.data = (int8_t*)(ser + 4);
7144         LDKHTLCUpdate ret_var = HTLCUpdate_read(ser_ref);
7145         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7146         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7147         long ret_ref = (long)ret_var.inner;
7148         if (ret_var.is_owned) {
7149                 ret_ref |= 1;
7150         }
7151         return ret_ref;
7152 }
7153
7154 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_ptr) {
7155         LDKChannelMonitor this_ptr_conv;
7156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7158         ChannelMonitor_free(this_ptr_conv);
7159 }
7160
7161 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
7162         LDKChannelMonitor obj_conv;
7163         obj_conv.inner = (void*)(obj & (~1));
7164         obj_conv.is_owned = false;
7165         LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
7166         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7167         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7168         CVec_u8Z_free(arg_var);
7169         return arg_arr;
7170 }
7171
7172 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) {
7173         LDKChannelMonitor this_arg_conv;
7174         this_arg_conv.inner = (void*)(this_arg & (~1));
7175         this_arg_conv.is_owned = false;
7176         LDKChannelMonitorUpdate updates_conv;
7177         updates_conv.inner = (void*)(updates & (~1));
7178         updates_conv.is_owned = false;
7179         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
7180         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
7181         LDKLogger* logger_conv = (LDKLogger*)logger;
7182         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7183         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
7184         return (long)ret_conv;
7185 }
7186
7187 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
7188         LDKChannelMonitor this_arg_conv;
7189         this_arg_conv.inner = (void*)(this_arg & (~1));
7190         this_arg_conv.is_owned = false;
7191         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
7192         return ret_val;
7193 }
7194
7195 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
7196         LDKChannelMonitor this_arg_conv;
7197         this_arg_conv.inner = (void*)(this_arg & (~1));
7198         this_arg_conv.is_owned = false;
7199         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7200         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
7201         ret_ref->a = OutPoint_clone(&ret_ref->a);
7202         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
7203         return (long)ret_ref;
7204 }
7205
7206 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
7207         LDKChannelMonitor this_arg_conv;
7208         this_arg_conv.inner = (void*)(this_arg & (~1));
7209         this_arg_conv.is_owned = false;
7210         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
7211         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7212         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7213         for (size_t o = 0; o < ret_var.datalen; o++) {
7214                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
7215                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7216                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7217                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
7218                 if (arr_conv_14_var.is_owned) {
7219                         arr_conv_14_ref |= 1;
7220                 }
7221                 ret_arr_ptr[o] = arr_conv_14_ref;
7222         }
7223         FREE(ret_var.data);
7224         return ret_arr;
7225 }
7226
7227 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
7228         LDKChannelMonitor this_arg_conv;
7229         this_arg_conv.inner = (void*)(this_arg & (~1));
7230         this_arg_conv.is_owned = false;
7231         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
7232         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7233         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7234         for (size_t h = 0; h < ret_var.datalen; h++) {
7235                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
7236                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
7237                 long arr_conv_7_ref = (long)arr_conv_7_copy;
7238                 ret_arr_ptr[h] = arr_conv_7_ref;
7239         }
7240         FREE(ret_var.data);
7241         return ret_arr;
7242 }
7243
7244 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
7245         LDKChannelMonitor this_arg_conv;
7246         this_arg_conv.inner = (void*)(this_arg & (~1));
7247         this_arg_conv.is_owned = false;
7248         LDKLogger* logger_conv = (LDKLogger*)logger;
7249         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
7250         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
7251         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
7252         for (size_t m = 0; m < ret_var.datalen; m++) {
7253                 LDKTransaction arr_conv_12_var = ret_var.data[m];
7254                 int8_tArray arr_conv_12_arr = init_arr(arr_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7255                 memcpy((uint8_t*)(arr_conv_12_arr + 4), arr_conv_12_var.data, arr_conv_12_var.datalen);
7256                 Transaction_free(arr_conv_12_var);
7257                 ret_arr_ptr[m] = arr_conv_12_arr;
7258         }
7259         FREE(ret_var.data);
7260         return ret_arr;
7261 }
7262
7263 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) {
7264         LDKChannelMonitor this_arg_conv;
7265         this_arg_conv.inner = (void*)(this_arg & (~1));
7266         this_arg_conv.is_owned = false;
7267         unsigned char header_arr[80];
7268         CHECK(*((uint32_t*)header) == 80);
7269         memcpy(header_arr, (uint8_t*)(header + 4), 80);
7270         unsigned char (*header_ref)[80] = &header_arr;
7271         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7272         txdata_constr.datalen = *((uint32_t*)txdata);
7273         if (txdata_constr.datalen > 0)
7274                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7275         else
7276                 txdata_constr.data = NULL;
7277         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
7278         for (size_t e = 0; e < txdata_constr.datalen; e++) {
7279                 uint32_t arr_conv_30 = txdata_vals[e];
7280                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
7281                 FREE((void*)arr_conv_30);
7282                 txdata_constr.data[e] = arr_conv_30_conv;
7283         }
7284         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
7285         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7286         LDKLogger logger_conv = *(LDKLogger*)logger;
7287         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);
7288         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7289         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7290         for (size_t x = 0; x < ret_var.datalen; x++) {
7291                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7292                 *arr_conv_49_ref = ret_var.data[x];
7293                 arr_conv_49_ref->a = ThirtyTwoBytes_clone(&arr_conv_49_ref->a);
7294                 arr_conv_49_ref->b = CVec_C2Tuple_u32TxOutZZ_clone(&arr_conv_49_ref->b);
7295                 ret_arr_ptr[x] = (long)arr_conv_49_ref;
7296         }
7297         FREE(ret_var.data);
7298         return ret_arr;
7299 }
7300
7301 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) {
7302         LDKChannelMonitor this_arg_conv;
7303         this_arg_conv.inner = (void*)(this_arg & (~1));
7304         this_arg_conv.is_owned = false;
7305         unsigned char header_arr[80];
7306         CHECK(*((uint32_t*)header) == 80);
7307         memcpy(header_arr, (uint8_t*)(header + 4), 80);
7308         unsigned char (*header_ref)[80] = &header_arr;
7309         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
7310         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7311         LDKLogger logger_conv = *(LDKLogger*)logger;
7312         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
7313 }
7314
7315 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
7316         LDKPersist this_ptr_conv = *(LDKPersist*)this_ptr;
7317         FREE((void*)this_ptr);
7318         Persist_free(this_ptr_conv);
7319 }
7320
7321 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
7322         LDKu8slice ser_ref;
7323         ser_ref.datalen = *((uint32_t*)ser);
7324         ser_ref.data = (int8_t*)(ser + 4);
7325         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
7326         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7327         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
7328         return (long)ret_conv;
7329 }
7330
7331 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_ptr) {
7332         LDKOutPoint this_ptr_conv;
7333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7334         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7335         OutPoint_free(this_ptr_conv);
7336 }
7337
7338 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
7339         LDKOutPoint orig_conv;
7340         orig_conv.inner = (void*)(orig & (~1));
7341         orig_conv.is_owned = false;
7342         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
7343         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7344         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7345         long ret_ref = (long)ret_var.inner;
7346         if (ret_var.is_owned) {
7347                 ret_ref |= 1;
7348         }
7349         return ret_ref;
7350 }
7351
7352 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
7353         LDKOutPoint this_ptr_conv;
7354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7355         this_ptr_conv.is_owned = false;
7356         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7357         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
7358         return ret_arr;
7359 }
7360
7361 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
7362         LDKOutPoint this_ptr_conv;
7363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7364         this_ptr_conv.is_owned = false;
7365         LDKThirtyTwoBytes val_ref;
7366         CHECK(*((uint32_t*)val) == 32);
7367         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7368         OutPoint_set_txid(&this_ptr_conv, val_ref);
7369 }
7370
7371 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
7372         LDKOutPoint this_ptr_conv;
7373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7374         this_ptr_conv.is_owned = false;
7375         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
7376         return ret_val;
7377 }
7378
7379 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
7380         LDKOutPoint this_ptr_conv;
7381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7382         this_ptr_conv.is_owned = false;
7383         OutPoint_set_index(&this_ptr_conv, val);
7384 }
7385
7386 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
7387         LDKThirtyTwoBytes txid_arg_ref;
7388         CHECK(*((uint32_t*)txid_arg) == 32);
7389         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
7390         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
7391         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7392         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7393         long ret_ref = (long)ret_var.inner;
7394         if (ret_var.is_owned) {
7395                 ret_ref |= 1;
7396         }
7397         return ret_ref;
7398 }
7399
7400 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
7401         LDKOutPoint this_arg_conv;
7402         this_arg_conv.inner = (void*)(this_arg & (~1));
7403         this_arg_conv.is_owned = false;
7404         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7405         memcpy((uint8_t*)(arg_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
7406         return arg_arr;
7407 }
7408
7409 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
7410         LDKOutPoint obj_conv;
7411         obj_conv.inner = (void*)(obj & (~1));
7412         obj_conv.is_owned = false;
7413         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
7414         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7415         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7416         CVec_u8Z_free(arg_var);
7417         return arg_arr;
7418 }
7419
7420 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
7421         LDKu8slice ser_ref;
7422         ser_ref.datalen = *((uint32_t*)ser);
7423         ser_ref.data = (int8_t*)(ser + 4);
7424         LDKOutPoint ret_var = OutPoint_read(ser_ref);
7425         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7426         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7427         long ret_ref = (long)ret_var.inner;
7428         if (ret_var.is_owned) {
7429                 ret_ref |= 1;
7430         }
7431         return ret_ref;
7432 }
7433
7434 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
7435         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
7436         FREE((void*)this_ptr);
7437         SpendableOutputDescriptor_free(this_ptr_conv);
7438 }
7439
7440 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
7441         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
7442         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
7443         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
7444         long ret_ref = (long)ret_copy;
7445         return ret_ref;
7446 }
7447
7448 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
7449         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
7450         LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
7451         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7452         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7453         CVec_u8Z_free(arg_var);
7454         return arg_arr;
7455 }
7456
7457 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
7458         LDKu8slice ser_ref;
7459         ser_ref.datalen = *((uint32_t*)ser);
7460         ser_ref.data = (int8_t*)(ser + 4);
7461         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7462         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
7463         return (long)ret_conv;
7464 }
7465
7466 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_clone(uint32_t orig) {
7467         LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
7468         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7469         *ret = ChannelKeys_clone(orig_conv);
7470         return (long)ret;
7471 }
7472
7473 void  __attribute__((visibility("default"))) TS_ChannelKeys_free(uint32_t this_ptr) {
7474         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
7475         FREE((void*)this_ptr);
7476         ChannelKeys_free(this_ptr_conv);
7477 }
7478
7479 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
7480         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
7481         FREE((void*)this_ptr);
7482         KeysInterface_free(this_ptr_conv);
7483 }
7484
7485 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_free(uint32_t this_ptr) {
7486         LDKInMemoryChannelKeys this_ptr_conv;
7487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7488         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7489         InMemoryChannelKeys_free(this_ptr_conv);
7490 }
7491
7492 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_clone(uint32_t orig) {
7493         LDKInMemoryChannelKeys orig_conv;
7494         orig_conv.inner = (void*)(orig & (~1));
7495         orig_conv.is_owned = false;
7496         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
7497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7499         long ret_ref = (long)ret_var.inner;
7500         if (ret_var.is_owned) {
7501                 ret_ref |= 1;
7502         }
7503         return ret_ref;
7504 }
7505
7506 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_funding_key(uint32_t this_ptr) {
7507         LDKInMemoryChannelKeys this_ptr_conv;
7508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7509         this_ptr_conv.is_owned = false;
7510         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7511         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_funding_key(&this_ptr_conv), 32);
7512         return ret_arr;
7513 }
7514
7515 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_funding_key(uint32_t this_ptr, int8_tArray val) {
7516         LDKInMemoryChannelKeys this_ptr_conv;
7517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7518         this_ptr_conv.is_owned = false;
7519         LDKSecretKey val_ref;
7520         CHECK(*((uint32_t*)val) == 32);
7521         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7522         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
7523 }
7524
7525 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_revocation_base_key(uint32_t this_ptr) {
7526         LDKInMemoryChannelKeys this_ptr_conv;
7527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7528         this_ptr_conv.is_owned = false;
7529         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7530         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv), 32);
7531         return ret_arr;
7532 }
7533
7534 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
7535         LDKInMemoryChannelKeys this_ptr_conv;
7536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7537         this_ptr_conv.is_owned = false;
7538         LDKSecretKey val_ref;
7539         CHECK(*((uint32_t*)val) == 32);
7540         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7541         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
7542 }
7543
7544 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_payment_key(uint32_t this_ptr) {
7545         LDKInMemoryChannelKeys this_ptr_conv;
7546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7547         this_ptr_conv.is_owned = false;
7548         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7549         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_payment_key(&this_ptr_conv), 32);
7550         return ret_arr;
7551 }
7552
7553 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_payment_key(uint32_t this_ptr, int8_tArray val) {
7554         LDKInMemoryChannelKeys this_ptr_conv;
7555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7556         this_ptr_conv.is_owned = false;
7557         LDKSecretKey val_ref;
7558         CHECK(*((uint32_t*)val) == 32);
7559         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7560         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
7561 }
7562
7563 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_delayed_payment_base_key(uint32_t this_ptr) {
7564         LDKInMemoryChannelKeys this_ptr_conv;
7565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7566         this_ptr_conv.is_owned = false;
7567         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7568         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv), 32);
7569         return ret_arr;
7570 }
7571
7572 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
7573         LDKInMemoryChannelKeys this_ptr_conv;
7574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7575         this_ptr_conv.is_owned = false;
7576         LDKSecretKey val_ref;
7577         CHECK(*((uint32_t*)val) == 32);
7578         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7579         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
7580 }
7581
7582 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_htlc_base_key(uint32_t this_ptr) {
7583         LDKInMemoryChannelKeys this_ptr_conv;
7584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7585         this_ptr_conv.is_owned = false;
7586         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7587         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv), 32);
7588         return ret_arr;
7589 }
7590
7591 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
7592         LDKInMemoryChannelKeys this_ptr_conv;
7593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7594         this_ptr_conv.is_owned = false;
7595         LDKSecretKey val_ref;
7596         CHECK(*((uint32_t*)val) == 32);
7597         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7598         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
7599 }
7600
7601 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_commitment_seed(uint32_t this_ptr) {
7602         LDKInMemoryChannelKeys this_ptr_conv;
7603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7604         this_ptr_conv.is_owned = false;
7605         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7606         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv), 32);
7607         return ret_arr;
7608 }
7609
7610 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
7611         LDKInMemoryChannelKeys this_ptr_conv;
7612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7613         this_ptr_conv.is_owned = false;
7614         LDKThirtyTwoBytes val_ref;
7615         CHECK(*((uint32_t*)val) == 32);
7616         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7617         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
7618 }
7619
7620 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_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, uint32_t key_derivation_params) {
7621         LDKSecretKey funding_key_ref;
7622         CHECK(*((uint32_t*)funding_key) == 32);
7623         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
7624         LDKSecretKey revocation_base_key_ref;
7625         CHECK(*((uint32_t*)revocation_base_key) == 32);
7626         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
7627         LDKSecretKey payment_key_ref;
7628         CHECK(*((uint32_t*)payment_key) == 32);
7629         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
7630         LDKSecretKey delayed_payment_base_key_ref;
7631         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
7632         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
7633         LDKSecretKey htlc_base_key_ref;
7634         CHECK(*((uint32_t*)htlc_base_key) == 32);
7635         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
7636         LDKThirtyTwoBytes commitment_seed_ref;
7637         CHECK(*((uint32_t*)commitment_seed) == 32);
7638         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
7639         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
7640         FREE((void*)key_derivation_params);
7641         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_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, key_derivation_params_conv);
7642         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7643         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7644         long ret_ref = (long)ret_var.inner;
7645         if (ret_var.is_owned) {
7646                 ret_ref |= 1;
7647         }
7648         return ret_ref;
7649 }
7650
7651 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_pubkeys(uint32_t this_arg) {
7652         LDKInMemoryChannelKeys this_arg_conv;
7653         this_arg_conv.inner = (void*)(this_arg & (~1));
7654         this_arg_conv.is_owned = false;
7655         LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
7656         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7657         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7658         long ret_ref = (long)ret_var.inner;
7659         if (ret_var.is_owned) {
7660                 ret_ref |= 1;
7661         }
7662         return ret_ref;
7663 }
7664
7665 int16_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_selected_contest_delay(uint32_t this_arg) {
7666         LDKInMemoryChannelKeys this_arg_conv;
7667         this_arg_conv.inner = (void*)(this_arg & (~1));
7668         this_arg_conv.is_owned = false;
7669         int16_t ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
7670         return ret_val;
7671 }
7672
7673 int16_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_holder_selected_contest_delay(uint32_t this_arg) {
7674         LDKInMemoryChannelKeys this_arg_conv;
7675         this_arg_conv.inner = (void*)(this_arg & (~1));
7676         this_arg_conv.is_owned = false;
7677         int16_t ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
7678         return ret_val;
7679 }
7680
7681 jboolean  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_is_outbound(uint32_t this_arg) {
7682         LDKInMemoryChannelKeys this_arg_conv;
7683         this_arg_conv.inner = (void*)(this_arg & (~1));
7684         this_arg_conv.is_owned = false;
7685         jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
7686         return ret_val;
7687 }
7688
7689 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_funding_outpoint(uint32_t this_arg) {
7690         LDKInMemoryChannelKeys this_arg_conv;
7691         this_arg_conv.inner = (void*)(this_arg & (~1));
7692         this_arg_conv.is_owned = false;
7693         LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
7694         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7695         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7696         long ret_ref = (long)ret_var.inner;
7697         if (ret_var.is_owned) {
7698                 ret_ref |= 1;
7699         }
7700         return ret_ref;
7701 }
7702
7703 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_channel_parameters(uint32_t this_arg) {
7704         LDKInMemoryChannelKeys this_arg_conv;
7705         this_arg_conv.inner = (void*)(this_arg & (~1));
7706         this_arg_conv.is_owned = false;
7707         LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
7708         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7709         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7710         long ret_ref = (long)ret_var.inner;
7711         if (ret_var.is_owned) {
7712                 ret_ref |= 1;
7713         }
7714         return ret_ref;
7715 }
7716
7717 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_as_ChannelKeys(uint32_t this_arg) {
7718         LDKInMemoryChannelKeys this_arg_conv;
7719         this_arg_conv.inner = (void*)(this_arg & (~1));
7720         this_arg_conv.is_owned = false;
7721         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7722         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
7723         return (long)ret;
7724 }
7725
7726 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_write(uint32_t obj) {
7727         LDKInMemoryChannelKeys obj_conv;
7728         obj_conv.inner = (void*)(obj & (~1));
7729         obj_conv.is_owned = false;
7730         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
7731         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7732         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7733         CVec_u8Z_free(arg_var);
7734         return arg_arr;
7735 }
7736
7737 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_read(int8_tArray ser) {
7738         LDKu8slice ser_ref;
7739         ser_ref.datalen = *((uint32_t*)ser);
7740         ser_ref.data = (int8_t*)(ser + 4);
7741         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7742         *ret_conv = InMemoryChannelKeys_read(ser_ref);
7743         return (long)ret_conv;
7744 }
7745
7746 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_ptr) {
7747         LDKKeysManager this_ptr_conv;
7748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7749         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7750         KeysManager_free(this_ptr_conv);
7751 }
7752
7753 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, uint32_t network, int64_t starting_time_secs, int32_t starting_time_nanos) {
7754         unsigned char seed_arr[32];
7755         CHECK(*((uint32_t*)seed) == 32);
7756         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
7757         unsigned char (*seed_ref)[32] = &seed_arr;
7758         LDKNetwork network_conv = LDKNetwork_from_js(network);
7759         LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
7760         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7761         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7762         long ret_ref = (long)ret_var.inner;
7763         if (ret_var.is_owned) {
7764                 ret_ref |= 1;
7765         }
7766         return ret_ref;
7767 }
7768
7769 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int64_t params_1, int64_t params_2) {
7770         LDKKeysManager this_arg_conv;
7771         this_arg_conv.inner = (void*)(this_arg & (~1));
7772         this_arg_conv.is_owned = false;
7773         LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
7774         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7775         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7776         long ret_ref = (long)ret_var.inner;
7777         if (ret_var.is_owned) {
7778                 ret_ref |= 1;
7779         }
7780         return ret_ref;
7781 }
7782
7783 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
7784         LDKKeysManager this_arg_conv;
7785         this_arg_conv.inner = (void*)(this_arg & (~1));
7786         this_arg_conv.is_owned = false;
7787         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7788         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
7789         return (long)ret;
7790 }
7791
7792 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_ptr) {
7793         LDKChannelManager this_ptr_conv;
7794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7795         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7796         ChannelManager_free(this_ptr_conv);
7797 }
7798
7799 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_ptr) {
7800         LDKChannelDetails this_ptr_conv;
7801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7802         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7803         ChannelDetails_free(this_ptr_conv);
7804 }
7805
7806 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
7807         LDKChannelDetails orig_conv;
7808         orig_conv.inner = (void*)(orig & (~1));
7809         orig_conv.is_owned = false;
7810         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
7811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7813         long ret_ref = (long)ret_var.inner;
7814         if (ret_var.is_owned) {
7815                 ret_ref |= 1;
7816         }
7817         return ret_ref;
7818 }
7819
7820 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
7821         LDKChannelDetails this_ptr_conv;
7822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7823         this_ptr_conv.is_owned = false;
7824         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7825         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
7826         return ret_arr;
7827 }
7828
7829 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
7830         LDKChannelDetails this_ptr_conv;
7831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7832         this_ptr_conv.is_owned = false;
7833         LDKThirtyTwoBytes val_ref;
7834         CHECK(*((uint32_t*)val) == 32);
7835         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7836         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
7837 }
7838
7839 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
7840         LDKChannelDetails this_ptr_conv;
7841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7842         this_ptr_conv.is_owned = false;
7843         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7844         memcpy((uint8_t*)(arg_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
7845         return arg_arr;
7846 }
7847
7848 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
7849         LDKChannelDetails this_ptr_conv;
7850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7851         this_ptr_conv.is_owned = false;
7852         LDKPublicKey val_ref;
7853         CHECK(*((uint32_t*)val) == 33);
7854         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
7855         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
7856 }
7857
7858 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
7859         LDKChannelDetails this_ptr_conv;
7860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7861         this_ptr_conv.is_owned = false;
7862         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
7863         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7864         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7865         long ret_ref = (long)ret_var.inner;
7866         if (ret_var.is_owned) {
7867                 ret_ref |= 1;
7868         }
7869         return ret_ref;
7870 }
7871
7872 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
7873         LDKChannelDetails this_ptr_conv;
7874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7875         this_ptr_conv.is_owned = false;
7876         LDKInitFeatures val_conv;
7877         val_conv.inner = (void*)(val & (~1));
7878         val_conv.is_owned = (val & 1) || (val == 0);
7879         // Warning: we may need a move here but can't clone!
7880         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
7881 }
7882
7883 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
7884         LDKChannelDetails this_ptr_conv;
7885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7886         this_ptr_conv.is_owned = false;
7887         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
7888         return ret_val;
7889 }
7890
7891 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
7892         LDKChannelDetails this_ptr_conv;
7893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7894         this_ptr_conv.is_owned = false;
7895         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
7896 }
7897
7898 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
7899         LDKChannelDetails this_ptr_conv;
7900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7901         this_ptr_conv.is_owned = false;
7902         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
7903         return ret_val;
7904 }
7905
7906 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
7907         LDKChannelDetails this_ptr_conv;
7908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7909         this_ptr_conv.is_owned = false;
7910         ChannelDetails_set_user_id(&this_ptr_conv, val);
7911 }
7912
7913 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
7914         LDKChannelDetails this_ptr_conv;
7915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7916         this_ptr_conv.is_owned = false;
7917         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
7918         return ret_val;
7919 }
7920
7921 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7922         LDKChannelDetails this_ptr_conv;
7923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7924         this_ptr_conv.is_owned = false;
7925         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
7926 }
7927
7928 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
7929         LDKChannelDetails this_ptr_conv;
7930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7931         this_ptr_conv.is_owned = false;
7932         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
7933         return ret_val;
7934 }
7935
7936 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7937         LDKChannelDetails this_ptr_conv;
7938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7939         this_ptr_conv.is_owned = false;
7940         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
7941 }
7942
7943 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
7944         LDKChannelDetails this_ptr_conv;
7945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7946         this_ptr_conv.is_owned = false;
7947         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
7948         return ret_val;
7949 }
7950
7951 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
7952         LDKChannelDetails this_ptr_conv;
7953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7954         this_ptr_conv.is_owned = false;
7955         ChannelDetails_set_is_live(&this_ptr_conv, val);
7956 }
7957
7958 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
7959         LDKPaymentSendFailure this_ptr_conv;
7960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7961         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7962         PaymentSendFailure_free(this_ptr_conv);
7963 }
7964
7965 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t network, uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, intptr_t current_blockchain_height) {
7966         LDKNetwork network_conv = LDKNetwork_from_js(network);
7967         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
7968         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7969         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7970         LDKLogger logger_conv = *(LDKLogger*)logger;
7971         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7972         LDKUserConfig config_conv;
7973         config_conv.inner = (void*)(config & (~1));
7974         config_conv.is_owned = (config & 1) || (config == 0);
7975         if (config_conv.inner != NULL)
7976                 config_conv = UserConfig_clone(&config_conv);
7977         LDKChannelManager ret_var = ChannelManager_new(network_conv, fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, current_blockchain_height);
7978         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7979         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7980         long ret_ref = (long)ret_var.inner;
7981         if (ret_var.is_owned) {
7982                 ret_ref |= 1;
7983         }
7984         return ret_ref;
7985 }
7986
7987 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) {
7988         LDKChannelManager this_arg_conv;
7989         this_arg_conv.inner = (void*)(this_arg & (~1));
7990         this_arg_conv.is_owned = false;
7991         LDKPublicKey their_network_key_ref;
7992         CHECK(*((uint32_t*)their_network_key) == 33);
7993         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
7994         LDKUserConfig override_config_conv;
7995         override_config_conv.inner = (void*)(override_config & (~1));
7996         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
7997         if (override_config_conv.inner != NULL)
7998                 override_config_conv = UserConfig_clone(&override_config_conv);
7999         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8000         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
8001         return (long)ret_conv;
8002 }
8003
8004 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
8005         LDKChannelManager this_arg_conv;
8006         this_arg_conv.inner = (void*)(this_arg & (~1));
8007         this_arg_conv.is_owned = false;
8008         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
8009         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
8010         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
8011         for (size_t q = 0; q < ret_var.datalen; q++) {
8012                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
8013                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8014                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8015                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
8016                 if (arr_conv_16_var.is_owned) {
8017                         arr_conv_16_ref |= 1;
8018                 }
8019                 ret_arr_ptr[q] = arr_conv_16_ref;
8020         }
8021         FREE(ret_var.data);
8022         return ret_arr;
8023 }
8024
8025 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
8026         LDKChannelManager this_arg_conv;
8027         this_arg_conv.inner = (void*)(this_arg & (~1));
8028         this_arg_conv.is_owned = false;
8029         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
8030         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
8031         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
8032         for (size_t q = 0; q < ret_var.datalen; q++) {
8033                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
8034                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8035                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8036                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
8037                 if (arr_conv_16_var.is_owned) {
8038                         arr_conv_16_ref |= 1;
8039                 }
8040                 ret_arr_ptr[q] = arr_conv_16_ref;
8041         }
8042         FREE(ret_var.data);
8043         return ret_arr;
8044 }
8045
8046 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
8047         LDKChannelManager this_arg_conv;
8048         this_arg_conv.inner = (void*)(this_arg & (~1));
8049         this_arg_conv.is_owned = false;
8050         unsigned char channel_id_arr[32];
8051         CHECK(*((uint32_t*)channel_id) == 32);
8052         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
8053         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
8054         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8055         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
8056         return (long)ret_conv;
8057 }
8058
8059 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
8060         LDKChannelManager this_arg_conv;
8061         this_arg_conv.inner = (void*)(this_arg & (~1));
8062         this_arg_conv.is_owned = false;
8063         unsigned char channel_id_arr[32];
8064         CHECK(*((uint32_t*)channel_id) == 32);
8065         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
8066         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
8067         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
8068 }
8069
8070 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
8071         LDKChannelManager this_arg_conv;
8072         this_arg_conv.inner = (void*)(this_arg & (~1));
8073         this_arg_conv.is_owned = false;
8074         ChannelManager_force_close_all_channels(&this_arg_conv);
8075 }
8076
8077 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
8078         LDKChannelManager this_arg_conv;
8079         this_arg_conv.inner = (void*)(this_arg & (~1));
8080         this_arg_conv.is_owned = false;
8081         LDKRoute route_conv;
8082         route_conv.inner = (void*)(route & (~1));
8083         route_conv.is_owned = false;
8084         LDKThirtyTwoBytes payment_hash_ref;
8085         CHECK(*((uint32_t*)payment_hash) == 32);
8086         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
8087         LDKThirtyTwoBytes payment_secret_ref;
8088         CHECK(*((uint32_t*)payment_secret) == 32);
8089         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8090         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8091         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
8092         return (long)ret_conv;
8093 }
8094
8095 void  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
8096         LDKChannelManager this_arg_conv;
8097         this_arg_conv.inner = (void*)(this_arg & (~1));
8098         this_arg_conv.is_owned = false;
8099         unsigned char temporary_channel_id_arr[32];
8100         CHECK(*((uint32_t*)temporary_channel_id) == 32);
8101         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
8102         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
8103         LDKOutPoint funding_txo_conv;
8104         funding_txo_conv.inner = (void*)(funding_txo & (~1));
8105         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
8106         if (funding_txo_conv.inner != NULL)
8107                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
8108         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
8109 }
8110
8111 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
8112         LDKChannelManager this_arg_conv;
8113         this_arg_conv.inner = (void*)(this_arg & (~1));
8114         this_arg_conv.is_owned = false;
8115         LDKThreeBytes rgb_ref;
8116         CHECK(*((uint32_t*)rgb) == 3);
8117         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
8118         LDKThirtyTwoBytes alias_ref;
8119         CHECK(*((uint32_t*)alias) == 32);
8120         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
8121         LDKCVec_NetAddressZ addresses_constr;
8122         addresses_constr.datalen = *((uint32_t*)addresses);
8123         if (addresses_constr.datalen > 0)
8124                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8125         else
8126                 addresses_constr.data = NULL;
8127         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
8128         for (size_t m = 0; m < addresses_constr.datalen; m++) {
8129                 uint32_t arr_conv_12 = addresses_vals[m];
8130                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
8131                 FREE((void*)arr_conv_12);
8132                 addresses_constr.data[m] = arr_conv_12_conv;
8133         }
8134         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
8135 }
8136
8137 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
8138         LDKChannelManager this_arg_conv;
8139         this_arg_conv.inner = (void*)(this_arg & (~1));
8140         this_arg_conv.is_owned = false;
8141         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
8142 }
8143
8144 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
8145         LDKChannelManager this_arg_conv;
8146         this_arg_conv.inner = (void*)(this_arg & (~1));
8147         this_arg_conv.is_owned = false;
8148         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
8149 }
8150
8151 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
8152         LDKChannelManager this_arg_conv;
8153         this_arg_conv.inner = (void*)(this_arg & (~1));
8154         this_arg_conv.is_owned = false;
8155         unsigned char payment_hash_arr[32];
8156         CHECK(*((uint32_t*)payment_hash) == 32);
8157         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
8158         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
8159         LDKThirtyTwoBytes payment_secret_ref;
8160         CHECK(*((uint32_t*)payment_secret) == 32);
8161         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8162         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
8163         return ret_val;
8164 }
8165
8166 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
8167         LDKChannelManager this_arg_conv;
8168         this_arg_conv.inner = (void*)(this_arg & (~1));
8169         this_arg_conv.is_owned = false;
8170         LDKThirtyTwoBytes payment_preimage_ref;
8171         CHECK(*((uint32_t*)payment_preimage) == 32);
8172         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
8173         LDKThirtyTwoBytes payment_secret_ref;
8174         CHECK(*((uint32_t*)payment_secret) == 32);
8175         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8176         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
8177         return ret_val;
8178 }
8179
8180 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
8181         LDKChannelManager this_arg_conv;
8182         this_arg_conv.inner = (void*)(this_arg & (~1));
8183         this_arg_conv.is_owned = false;
8184         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8185         memcpy((uint8_t*)(arg_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
8186         return arg_arr;
8187 }
8188
8189 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
8190         LDKChannelManager this_arg_conv;
8191         this_arg_conv.inner = (void*)(this_arg & (~1));
8192         this_arg_conv.is_owned = false;
8193         LDKOutPoint funding_txo_conv;
8194         funding_txo_conv.inner = (void*)(funding_txo & (~1));
8195         funding_txo_conv.is_owned = false;
8196         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
8197 }
8198
8199 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
8200         LDKChannelManager this_arg_conv;
8201         this_arg_conv.inner = (void*)(this_arg & (~1));
8202         this_arg_conv.is_owned = false;
8203         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8204         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
8205         return (long)ret;
8206 }
8207
8208 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
8209         LDKChannelManager this_arg_conv;
8210         this_arg_conv.inner = (void*)(this_arg & (~1));
8211         this_arg_conv.is_owned = false;
8212         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8213         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
8214         return (long)ret;
8215 }
8216
8217 void  __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
8218         LDKChannelManager this_arg_conv;
8219         this_arg_conv.inner = (void*)(this_arg & (~1));
8220         this_arg_conv.is_owned = false;
8221         unsigned char header_arr[80];
8222         CHECK(*((uint32_t*)header) == 80);
8223         memcpy(header_arr, (uint8_t*)(header + 4), 80);
8224         unsigned char (*header_ref)[80] = &header_arr;
8225         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8226         txdata_constr.datalen = *((uint32_t*)txdata);
8227         if (txdata_constr.datalen > 0)
8228                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8229         else
8230                 txdata_constr.data = NULL;
8231         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
8232         for (size_t e = 0; e < txdata_constr.datalen; e++) {
8233                 uint32_t arr_conv_30 = txdata_vals[e];
8234                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
8235                 FREE((void*)arr_conv_30);
8236                 txdata_constr.data[e] = arr_conv_30_conv;
8237         }
8238         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
8239 }
8240
8241 void  __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
8242         LDKChannelManager this_arg_conv;
8243         this_arg_conv.inner = (void*)(this_arg & (~1));
8244         this_arg_conv.is_owned = false;
8245         unsigned char header_arr[80];
8246         CHECK(*((uint32_t*)header) == 80);
8247         memcpy(header_arr, (uint8_t*)(header + 4), 80);
8248         unsigned char (*header_ref)[80] = &header_arr;
8249         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
8250 }
8251
8252 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
8253         LDKChannelManager this_arg_conv;
8254         this_arg_conv.inner = (void*)(this_arg & (~1));
8255         this_arg_conv.is_owned = false;
8256         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8257         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
8258         return (long)ret;
8259 }
8260
8261 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
8262         LDKChannelManager obj_conv;
8263         obj_conv.inner = (void*)(obj & (~1));
8264         obj_conv.is_owned = false;
8265         LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
8266         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8267         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
8268         CVec_u8Z_free(arg_var);
8269         return arg_arr;
8270 }
8271
8272 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_ptr) {
8273         LDKChannelManagerReadArgs this_ptr_conv;
8274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8275         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8276         ChannelManagerReadArgs_free(this_ptr_conv);
8277 }
8278
8279 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
8280         LDKChannelManagerReadArgs this_ptr_conv;
8281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8282         this_ptr_conv.is_owned = false;
8283         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
8284         return ret_ret;
8285 }
8286
8287 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
8288         LDKChannelManagerReadArgs this_ptr_conv;
8289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8290         this_ptr_conv.is_owned = false;
8291         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
8292         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
8293 }
8294
8295 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
8296         LDKChannelManagerReadArgs this_ptr_conv;
8297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8298         this_ptr_conv.is_owned = false;
8299         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
8300         return ret_ret;
8301 }
8302
8303 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
8304         LDKChannelManagerReadArgs this_ptr_conv;
8305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8306         this_ptr_conv.is_owned = false;
8307         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
8308         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
8309 }
8310
8311 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
8312         LDKChannelManagerReadArgs this_ptr_conv;
8313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8314         this_ptr_conv.is_owned = false;
8315         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
8316         return ret_ret;
8317 }
8318
8319 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
8320         LDKChannelManagerReadArgs this_ptr_conv;
8321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8322         this_ptr_conv.is_owned = false;
8323         LDKWatch val_conv = *(LDKWatch*)val;
8324         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
8325 }
8326
8327 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
8328         LDKChannelManagerReadArgs this_ptr_conv;
8329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8330         this_ptr_conv.is_owned = false;
8331         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
8332         return ret_ret;
8333 }
8334
8335 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
8336         LDKChannelManagerReadArgs this_ptr_conv;
8337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8338         this_ptr_conv.is_owned = false;
8339         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
8340         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
8341 }
8342
8343 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
8344         LDKChannelManagerReadArgs this_ptr_conv;
8345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8346         this_ptr_conv.is_owned = false;
8347         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
8348         return ret_ret;
8349 }
8350
8351 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
8352         LDKChannelManagerReadArgs this_ptr_conv;
8353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8354         this_ptr_conv.is_owned = false;
8355         LDKLogger val_conv = *(LDKLogger*)val;
8356         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
8357 }
8358
8359 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
8360         LDKChannelManagerReadArgs this_ptr_conv;
8361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8362         this_ptr_conv.is_owned = false;
8363         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
8364         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8365         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8366         long ret_ref = (long)ret_var.inner;
8367         if (ret_var.is_owned) {
8368                 ret_ref |= 1;
8369         }
8370         return ret_ref;
8371 }
8372
8373 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
8374         LDKChannelManagerReadArgs this_ptr_conv;
8375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8376         this_ptr_conv.is_owned = false;
8377         LDKUserConfig val_conv;
8378         val_conv.inner = (void*)(val & (~1));
8379         val_conv.is_owned = (val & 1) || (val == 0);
8380         if (val_conv.inner != NULL)
8381                 val_conv = UserConfig_clone(&val_conv);
8382         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
8383 }
8384
8385 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) {
8386         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
8387         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
8388         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
8389         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
8390         LDKLogger logger_conv = *(LDKLogger*)logger;
8391         LDKUserConfig default_config_conv;
8392         default_config_conv.inner = (void*)(default_config & (~1));
8393         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
8394         if (default_config_conv.inner != NULL)
8395                 default_config_conv = UserConfig_clone(&default_config_conv);
8396         LDKCVec_ChannelMonitorZ channel_monitors_constr;
8397         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
8398         if (channel_monitors_constr.datalen > 0)
8399                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8400         else
8401                 channel_monitors_constr.data = NULL;
8402         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
8403         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
8404                 uint32_t arr_conv_16 = channel_monitors_vals[q];
8405                 LDKChannelMonitor arr_conv_16_conv;
8406                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
8407                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
8408                 // Warning: we may need a move here but can't clone!
8409                 channel_monitors_constr.data[q] = arr_conv_16_conv;
8410         }
8411         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);
8412         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8413         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8414         long ret_ref = (long)ret_var.inner;
8415         if (ret_var.is_owned) {
8416                 ret_ref |= 1;
8417         }
8418         return ret_ref;
8419 }
8420
8421 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
8422         LDKu8slice ser_ref;
8423         ser_ref.datalen = *((uint32_t*)ser);
8424         ser_ref.data = (int8_t*)(ser + 4);
8425         LDKChannelManagerReadArgs arg_conv;
8426         arg_conv.inner = (void*)(arg & (~1));
8427         arg_conv.is_owned = (arg & 1) || (arg == 0);
8428         // Warning: we may need a move here but can't clone!
8429         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8430         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
8431         return (long)ret_conv;
8432 }
8433
8434 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_ptr) {
8435         LDKDecodeError this_ptr_conv;
8436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8437         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8438         DecodeError_free(this_ptr_conv);
8439 }
8440
8441 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_ptr) {
8442         LDKInit this_ptr_conv;
8443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8444         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8445         Init_free(this_ptr_conv);
8446 }
8447
8448 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
8449         LDKInit orig_conv;
8450         orig_conv.inner = (void*)(orig & (~1));
8451         orig_conv.is_owned = false;
8452         LDKInit ret_var = Init_clone(&orig_conv);
8453         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8454         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8455         long ret_ref = (long)ret_var.inner;
8456         if (ret_var.is_owned) {
8457                 ret_ref |= 1;
8458         }
8459         return ret_ref;
8460 }
8461
8462 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_ptr) {
8463         LDKErrorMessage this_ptr_conv;
8464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8465         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8466         ErrorMessage_free(this_ptr_conv);
8467 }
8468
8469 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
8470         LDKErrorMessage orig_conv;
8471         orig_conv.inner = (void*)(orig & (~1));
8472         orig_conv.is_owned = false;
8473         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
8474         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8475         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8476         long ret_ref = (long)ret_var.inner;
8477         if (ret_var.is_owned) {
8478                 ret_ref |= 1;
8479         }
8480         return ret_ref;
8481 }
8482
8483 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
8484         LDKErrorMessage this_ptr_conv;
8485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8486         this_ptr_conv.is_owned = false;
8487         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8488         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
8489         return ret_arr;
8490 }
8491
8492 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
8493         LDKErrorMessage this_ptr_conv;
8494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8495         this_ptr_conv.is_owned = false;
8496         LDKThirtyTwoBytes val_ref;
8497         CHECK(*((uint32_t*)val) == 32);
8498         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8499         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
8500 }
8501
8502 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
8503         LDKErrorMessage this_ptr_conv;
8504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8505         this_ptr_conv.is_owned = false;
8506         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
8507         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
8508         return _conv;
8509 }
8510
8511 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
8512         LDKErrorMessage this_ptr_conv;
8513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8514         this_ptr_conv.is_owned = false;
8515         LDKCVec_u8Z val_ref;
8516         val_ref.datalen = *((uint32_t*)val);
8517         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
8518         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
8519         ErrorMessage_set_data(&this_ptr_conv, val_ref);
8520 }
8521
8522 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
8523         LDKThirtyTwoBytes channel_id_arg_ref;
8524         CHECK(*((uint32_t*)channel_id_arg) == 32);
8525         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
8526         LDKCVec_u8Z data_arg_ref;
8527         data_arg_ref.datalen = *((uint32_t*)data_arg);
8528         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
8529         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
8530         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
8531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8533         long ret_ref = (long)ret_var.inner;
8534         if (ret_var.is_owned) {
8535                 ret_ref |= 1;
8536         }
8537         return ret_ref;
8538 }
8539
8540 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_ptr) {
8541         LDKPing this_ptr_conv;
8542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8543         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8544         Ping_free(this_ptr_conv);
8545 }
8546
8547 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
8548         LDKPing orig_conv;
8549         orig_conv.inner = (void*)(orig & (~1));
8550         orig_conv.is_owned = false;
8551         LDKPing ret_var = Ping_clone(&orig_conv);
8552         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8553         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8554         long ret_ref = (long)ret_var.inner;
8555         if (ret_var.is_owned) {
8556                 ret_ref |= 1;
8557         }
8558         return ret_ref;
8559 }
8560
8561 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
8562         LDKPing this_ptr_conv;
8563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8564         this_ptr_conv.is_owned = false;
8565         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
8566         return ret_val;
8567 }
8568
8569 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
8570         LDKPing this_ptr_conv;
8571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8572         this_ptr_conv.is_owned = false;
8573         Ping_set_ponglen(&this_ptr_conv, val);
8574 }
8575
8576 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
8577         LDKPing this_ptr_conv;
8578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8579         this_ptr_conv.is_owned = false;
8580         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
8581         return ret_val;
8582 }
8583
8584 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
8585         LDKPing this_ptr_conv;
8586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8587         this_ptr_conv.is_owned = false;
8588         Ping_set_byteslen(&this_ptr_conv, val);
8589 }
8590
8591 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
8592         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
8593         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8594         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8595         long ret_ref = (long)ret_var.inner;
8596         if (ret_var.is_owned) {
8597                 ret_ref |= 1;
8598         }
8599         return ret_ref;
8600 }
8601
8602 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_ptr) {
8603         LDKPong this_ptr_conv;
8604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8606         Pong_free(this_ptr_conv);
8607 }
8608
8609 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
8610         LDKPong orig_conv;
8611         orig_conv.inner = (void*)(orig & (~1));
8612         orig_conv.is_owned = false;
8613         LDKPong ret_var = Pong_clone(&orig_conv);
8614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8616         long ret_ref = (long)ret_var.inner;
8617         if (ret_var.is_owned) {
8618                 ret_ref |= 1;
8619         }
8620         return ret_ref;
8621 }
8622
8623 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
8624         LDKPong this_ptr_conv;
8625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8626         this_ptr_conv.is_owned = false;
8627         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
8628         return ret_val;
8629 }
8630
8631 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
8632         LDKPong this_ptr_conv;
8633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8634         this_ptr_conv.is_owned = false;
8635         Pong_set_byteslen(&this_ptr_conv, val);
8636 }
8637
8638 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
8639         LDKPong ret_var = Pong_new(byteslen_arg);
8640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8642         long ret_ref = (long)ret_var.inner;
8643         if (ret_var.is_owned) {
8644                 ret_ref |= 1;
8645         }
8646         return ret_ref;
8647 }
8648
8649 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_ptr) {
8650         LDKOpenChannel this_ptr_conv;
8651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8652         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8653         OpenChannel_free(this_ptr_conv);
8654 }
8655
8656 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
8657         LDKOpenChannel orig_conv;
8658         orig_conv.inner = (void*)(orig & (~1));
8659         orig_conv.is_owned = false;
8660         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
8661         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8662         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8663         long ret_ref = (long)ret_var.inner;
8664         if (ret_var.is_owned) {
8665                 ret_ref |= 1;
8666         }
8667         return ret_ref;
8668 }
8669
8670 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
8671         LDKOpenChannel this_ptr_conv;
8672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8673         this_ptr_conv.is_owned = false;
8674         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8675         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
8676         return ret_arr;
8677 }
8678
8679 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
8680         LDKOpenChannel this_ptr_conv;
8681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8682         this_ptr_conv.is_owned = false;
8683         LDKThirtyTwoBytes val_ref;
8684         CHECK(*((uint32_t*)val) == 32);
8685         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8686         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
8687 }
8688
8689 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
8690         LDKOpenChannel this_ptr_conv;
8691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8692         this_ptr_conv.is_owned = false;
8693         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8694         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8695         return ret_arr;
8696 }
8697
8698 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
8699         LDKOpenChannel this_ptr_conv;
8700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8701         this_ptr_conv.is_owned = false;
8702         LDKThirtyTwoBytes val_ref;
8703         CHECK(*((uint32_t*)val) == 32);
8704         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8705         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8706 }
8707
8708 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
8709         LDKOpenChannel this_ptr_conv;
8710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8711         this_ptr_conv.is_owned = false;
8712         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
8713         return ret_val;
8714 }
8715
8716 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
8717         LDKOpenChannel this_ptr_conv;
8718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8719         this_ptr_conv.is_owned = false;
8720         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
8721 }
8722
8723 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
8724         LDKOpenChannel this_ptr_conv;
8725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8726         this_ptr_conv.is_owned = false;
8727         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
8728         return ret_val;
8729 }
8730
8731 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
8732         LDKOpenChannel this_ptr_conv;
8733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8734         this_ptr_conv.is_owned = false;
8735         OpenChannel_set_push_msat(&this_ptr_conv, val);
8736 }
8737
8738 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
8739         LDKOpenChannel this_ptr_conv;
8740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8741         this_ptr_conv.is_owned = false;
8742         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
8743         return ret_val;
8744 }
8745
8746 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8747         LDKOpenChannel this_ptr_conv;
8748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8749         this_ptr_conv.is_owned = false;
8750         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8751 }
8752
8753 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8754         LDKOpenChannel this_ptr_conv;
8755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8756         this_ptr_conv.is_owned = false;
8757         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8758         return ret_val;
8759 }
8760
8761 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8762         LDKOpenChannel this_ptr_conv;
8763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8764         this_ptr_conv.is_owned = false;
8765         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8766 }
8767
8768 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
8769         LDKOpenChannel this_ptr_conv;
8770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8771         this_ptr_conv.is_owned = false;
8772         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8773         return ret_val;
8774 }
8775
8776 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8777         LDKOpenChannel this_ptr_conv;
8778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8779         this_ptr_conv.is_owned = false;
8780         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8781 }
8782
8783 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
8784         LDKOpenChannel this_ptr_conv;
8785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8786         this_ptr_conv.is_owned = false;
8787         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
8788         return ret_val;
8789 }
8790
8791 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8792         LDKOpenChannel this_ptr_conv;
8793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8794         this_ptr_conv.is_owned = false;
8795         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
8796 }
8797
8798 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
8799         LDKOpenChannel this_ptr_conv;
8800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8801         this_ptr_conv.is_owned = false;
8802         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
8803         return ret_val;
8804 }
8805
8806 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
8807         LDKOpenChannel this_ptr_conv;
8808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8809         this_ptr_conv.is_owned = false;
8810         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
8811 }
8812
8813 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
8814         LDKOpenChannel this_ptr_conv;
8815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8816         this_ptr_conv.is_owned = false;
8817         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
8818         return ret_val;
8819 }
8820
8821 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
8822         LDKOpenChannel this_ptr_conv;
8823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8824         this_ptr_conv.is_owned = false;
8825         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
8826 }
8827
8828 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
8829         LDKOpenChannel this_ptr_conv;
8830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8831         this_ptr_conv.is_owned = false;
8832         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
8833         return ret_val;
8834 }
8835
8836 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
8837         LDKOpenChannel this_ptr_conv;
8838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8839         this_ptr_conv.is_owned = false;
8840         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
8841 }
8842
8843 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
8844         LDKOpenChannel this_ptr_conv;
8845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8846         this_ptr_conv.is_owned = false;
8847         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8848         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
8849         return arg_arr;
8850 }
8851
8852 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
8853         LDKOpenChannel this_ptr_conv;
8854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8855         this_ptr_conv.is_owned = false;
8856         LDKPublicKey val_ref;
8857         CHECK(*((uint32_t*)val) == 33);
8858         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8859         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
8860 }
8861
8862 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
8863         LDKOpenChannel this_ptr_conv;
8864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8865         this_ptr_conv.is_owned = false;
8866         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8867         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
8868         return arg_arr;
8869 }
8870
8871 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
8872         LDKOpenChannel this_ptr_conv;
8873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8874         this_ptr_conv.is_owned = false;
8875         LDKPublicKey val_ref;
8876         CHECK(*((uint32_t*)val) == 33);
8877         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8878         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
8879 }
8880
8881 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
8882         LDKOpenChannel this_ptr_conv;
8883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8884         this_ptr_conv.is_owned = false;
8885         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8886         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
8887         return arg_arr;
8888 }
8889
8890 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
8891         LDKOpenChannel this_ptr_conv;
8892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8893         this_ptr_conv.is_owned = false;
8894         LDKPublicKey val_ref;
8895         CHECK(*((uint32_t*)val) == 33);
8896         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8897         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
8898 }
8899
8900 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
8901         LDKOpenChannel this_ptr_conv;
8902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8903         this_ptr_conv.is_owned = false;
8904         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8905         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
8906         return arg_arr;
8907 }
8908
8909 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
8910         LDKOpenChannel this_ptr_conv;
8911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8912         this_ptr_conv.is_owned = false;
8913         LDKPublicKey val_ref;
8914         CHECK(*((uint32_t*)val) == 33);
8915         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8916         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
8917 }
8918
8919 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
8920         LDKOpenChannel this_ptr_conv;
8921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8922         this_ptr_conv.is_owned = false;
8923         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8924         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
8925         return arg_arr;
8926 }
8927
8928 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
8929         LDKOpenChannel this_ptr_conv;
8930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8931         this_ptr_conv.is_owned = false;
8932         LDKPublicKey val_ref;
8933         CHECK(*((uint32_t*)val) == 33);
8934         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8935         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
8936 }
8937
8938 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
8939         LDKOpenChannel this_ptr_conv;
8940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8941         this_ptr_conv.is_owned = false;
8942         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8943         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8944         return arg_arr;
8945 }
8946
8947 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
8948         LDKOpenChannel this_ptr_conv;
8949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8950         this_ptr_conv.is_owned = false;
8951         LDKPublicKey val_ref;
8952         CHECK(*((uint32_t*)val) == 33);
8953         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8954         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
8955 }
8956
8957 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
8958         LDKOpenChannel this_ptr_conv;
8959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8960         this_ptr_conv.is_owned = false;
8961         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
8962         return ret_val;
8963 }
8964
8965 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
8966         LDKOpenChannel this_ptr_conv;
8967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8968         this_ptr_conv.is_owned = false;
8969         OpenChannel_set_channel_flags(&this_ptr_conv, val);
8970 }
8971
8972 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_ptr) {
8973         LDKAcceptChannel this_ptr_conv;
8974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8975         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8976         AcceptChannel_free(this_ptr_conv);
8977 }
8978
8979 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
8980         LDKAcceptChannel orig_conv;
8981         orig_conv.inner = (void*)(orig & (~1));
8982         orig_conv.is_owned = false;
8983         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
8984         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8985         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8986         long ret_ref = (long)ret_var.inner;
8987         if (ret_var.is_owned) {
8988                 ret_ref |= 1;
8989         }
8990         return ret_ref;
8991 }
8992
8993 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
8994         LDKAcceptChannel this_ptr_conv;
8995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8996         this_ptr_conv.is_owned = false;
8997         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8998         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8999         return ret_arr;
9000 }
9001
9002 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
9003         LDKAcceptChannel this_ptr_conv;
9004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9005         this_ptr_conv.is_owned = false;
9006         LDKThirtyTwoBytes val_ref;
9007         CHECK(*((uint32_t*)val) == 32);
9008         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9009         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
9010 }
9011
9012 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
9013         LDKAcceptChannel this_ptr_conv;
9014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9015         this_ptr_conv.is_owned = false;
9016         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
9017         return ret_val;
9018 }
9019
9020 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
9021         LDKAcceptChannel this_ptr_conv;
9022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9023         this_ptr_conv.is_owned = false;
9024         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
9025 }
9026
9027 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
9028         LDKAcceptChannel this_ptr_conv;
9029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9030         this_ptr_conv.is_owned = false;
9031         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
9032         return ret_val;
9033 }
9034
9035 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
9036         LDKAcceptChannel this_ptr_conv;
9037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9038         this_ptr_conv.is_owned = false;
9039         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
9040 }
9041
9042 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
9043         LDKAcceptChannel this_ptr_conv;
9044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9045         this_ptr_conv.is_owned = false;
9046         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
9047         return ret_val;
9048 }
9049
9050 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
9051         LDKAcceptChannel this_ptr_conv;
9052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9053         this_ptr_conv.is_owned = false;
9054         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
9055 }
9056
9057 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
9058         LDKAcceptChannel this_ptr_conv;
9059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9060         this_ptr_conv.is_owned = false;
9061         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
9062         return ret_val;
9063 }
9064
9065 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9066         LDKAcceptChannel this_ptr_conv;
9067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9068         this_ptr_conv.is_owned = false;
9069         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
9070 }
9071
9072 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
9073         LDKAcceptChannel this_ptr_conv;
9074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9075         this_ptr_conv.is_owned = false;
9076         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
9077         return ret_val;
9078 }
9079
9080 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
9081         LDKAcceptChannel this_ptr_conv;
9082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9083         this_ptr_conv.is_owned = false;
9084         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
9085 }
9086
9087 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
9088         LDKAcceptChannel this_ptr_conv;
9089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9090         this_ptr_conv.is_owned = false;
9091         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
9092         return ret_val;
9093 }
9094
9095 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
9096         LDKAcceptChannel this_ptr_conv;
9097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9098         this_ptr_conv.is_owned = false;
9099         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
9100 }
9101
9102 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
9103         LDKAcceptChannel this_ptr_conv;
9104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9105         this_ptr_conv.is_owned = false;
9106         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
9107         return ret_val;
9108 }
9109
9110 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
9111         LDKAcceptChannel this_ptr_conv;
9112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9113         this_ptr_conv.is_owned = false;
9114         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
9115 }
9116
9117 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
9118         LDKAcceptChannel this_ptr_conv;
9119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9120         this_ptr_conv.is_owned = false;
9121         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9122         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
9123         return arg_arr;
9124 }
9125
9126 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
9127         LDKAcceptChannel this_ptr_conv;
9128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9129         this_ptr_conv.is_owned = false;
9130         LDKPublicKey val_ref;
9131         CHECK(*((uint32_t*)val) == 33);
9132         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9133         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
9134 }
9135
9136 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
9137         LDKAcceptChannel this_ptr_conv;
9138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9139         this_ptr_conv.is_owned = false;
9140         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9141         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
9142         return arg_arr;
9143 }
9144
9145 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
9146         LDKAcceptChannel this_ptr_conv;
9147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9148         this_ptr_conv.is_owned = false;
9149         LDKPublicKey val_ref;
9150         CHECK(*((uint32_t*)val) == 33);
9151         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9152         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
9153 }
9154
9155 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
9156         LDKAcceptChannel this_ptr_conv;
9157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9158         this_ptr_conv.is_owned = false;
9159         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9160         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
9161         return arg_arr;
9162 }
9163
9164 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
9165         LDKAcceptChannel this_ptr_conv;
9166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9167         this_ptr_conv.is_owned = false;
9168         LDKPublicKey val_ref;
9169         CHECK(*((uint32_t*)val) == 33);
9170         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9171         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
9172 }
9173
9174 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
9175         LDKAcceptChannel this_ptr_conv;
9176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9177         this_ptr_conv.is_owned = false;
9178         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9179         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
9180         return arg_arr;
9181 }
9182
9183 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
9184         LDKAcceptChannel this_ptr_conv;
9185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9186         this_ptr_conv.is_owned = false;
9187         LDKPublicKey val_ref;
9188         CHECK(*((uint32_t*)val) == 33);
9189         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9190         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
9191 }
9192
9193 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
9194         LDKAcceptChannel this_ptr_conv;
9195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9196         this_ptr_conv.is_owned = false;
9197         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9198         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
9199         return arg_arr;
9200 }
9201
9202 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
9203         LDKAcceptChannel this_ptr_conv;
9204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9205         this_ptr_conv.is_owned = false;
9206         LDKPublicKey val_ref;
9207         CHECK(*((uint32_t*)val) == 33);
9208         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9209         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
9210 }
9211
9212 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
9213         LDKAcceptChannel this_ptr_conv;
9214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9215         this_ptr_conv.is_owned = false;
9216         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9217         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9218         return arg_arr;
9219 }
9220
9221 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9222         LDKAcceptChannel this_ptr_conv;
9223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9224         this_ptr_conv.is_owned = false;
9225         LDKPublicKey val_ref;
9226         CHECK(*((uint32_t*)val) == 33);
9227         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9228         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
9229 }
9230
9231 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_ptr) {
9232         LDKFundingCreated this_ptr_conv;
9233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9234         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9235         FundingCreated_free(this_ptr_conv);
9236 }
9237
9238 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
9239         LDKFundingCreated orig_conv;
9240         orig_conv.inner = (void*)(orig & (~1));
9241         orig_conv.is_owned = false;
9242         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
9243         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9244         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9245         long ret_ref = (long)ret_var.inner;
9246         if (ret_var.is_owned) {
9247                 ret_ref |= 1;
9248         }
9249         return ret_ref;
9250 }
9251
9252 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
9253         LDKFundingCreated this_ptr_conv;
9254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9255         this_ptr_conv.is_owned = false;
9256         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9257         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
9258         return ret_arr;
9259 }
9260
9261 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
9262         LDKFundingCreated this_ptr_conv;
9263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9264         this_ptr_conv.is_owned = false;
9265         LDKThirtyTwoBytes val_ref;
9266         CHECK(*((uint32_t*)val) == 32);
9267         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9268         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
9269 }
9270
9271 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
9272         LDKFundingCreated this_ptr_conv;
9273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9274         this_ptr_conv.is_owned = false;
9275         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9276         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
9277         return ret_arr;
9278 }
9279
9280 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
9281         LDKFundingCreated this_ptr_conv;
9282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9283         this_ptr_conv.is_owned = false;
9284         LDKThirtyTwoBytes val_ref;
9285         CHECK(*((uint32_t*)val) == 32);
9286         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9287         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
9288 }
9289
9290 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
9291         LDKFundingCreated this_ptr_conv;
9292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9293         this_ptr_conv.is_owned = false;
9294         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
9295         return ret_val;
9296 }
9297
9298 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
9299         LDKFundingCreated this_ptr_conv;
9300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9301         this_ptr_conv.is_owned = false;
9302         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
9303 }
9304
9305 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
9306         LDKFundingCreated this_ptr_conv;
9307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9308         this_ptr_conv.is_owned = false;
9309         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9310         memcpy((uint8_t*)(arg_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
9311         return arg_arr;
9312 }
9313
9314 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
9315         LDKFundingCreated this_ptr_conv;
9316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9317         this_ptr_conv.is_owned = false;
9318         LDKSignature val_ref;
9319         CHECK(*((uint32_t*)val) == 64);
9320         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9321         FundingCreated_set_signature(&this_ptr_conv, val_ref);
9322 }
9323
9324 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) {
9325         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
9326         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
9327         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
9328         LDKThirtyTwoBytes funding_txid_arg_ref;
9329         CHECK(*((uint32_t*)funding_txid_arg) == 32);
9330         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
9331         LDKSignature signature_arg_ref;
9332         CHECK(*((uint32_t*)signature_arg) == 64);
9333         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9334         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
9335         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9336         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9337         long ret_ref = (long)ret_var.inner;
9338         if (ret_var.is_owned) {
9339                 ret_ref |= 1;
9340         }
9341         return ret_ref;
9342 }
9343
9344 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_ptr) {
9345         LDKFundingSigned this_ptr_conv;
9346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9347         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9348         FundingSigned_free(this_ptr_conv);
9349 }
9350
9351 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
9352         LDKFundingSigned orig_conv;
9353         orig_conv.inner = (void*)(orig & (~1));
9354         orig_conv.is_owned = false;
9355         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
9356         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9357         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9358         long ret_ref = (long)ret_var.inner;
9359         if (ret_var.is_owned) {
9360                 ret_ref |= 1;
9361         }
9362         return ret_ref;
9363 }
9364
9365 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
9366         LDKFundingSigned this_ptr_conv;
9367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9368         this_ptr_conv.is_owned = false;
9369         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9370         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
9371         return ret_arr;
9372 }
9373
9374 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9375         LDKFundingSigned this_ptr_conv;
9376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9377         this_ptr_conv.is_owned = false;
9378         LDKThirtyTwoBytes val_ref;
9379         CHECK(*((uint32_t*)val) == 32);
9380         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9381         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
9382 }
9383
9384 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
9385         LDKFundingSigned this_ptr_conv;
9386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9387         this_ptr_conv.is_owned = false;
9388         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9389         memcpy((uint8_t*)(arg_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9390         return arg_arr;
9391 }
9392
9393 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9394         LDKFundingSigned this_ptr_conv;
9395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9396         this_ptr_conv.is_owned = false;
9397         LDKSignature val_ref;
9398         CHECK(*((uint32_t*)val) == 64);
9399         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9400         FundingSigned_set_signature(&this_ptr_conv, val_ref);
9401 }
9402
9403 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
9404         LDKThirtyTwoBytes channel_id_arg_ref;
9405         CHECK(*((uint32_t*)channel_id_arg) == 32);
9406         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9407         LDKSignature signature_arg_ref;
9408         CHECK(*((uint32_t*)signature_arg) == 64);
9409         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9410         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
9411         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9412         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9413         long ret_ref = (long)ret_var.inner;
9414         if (ret_var.is_owned) {
9415                 ret_ref |= 1;
9416         }
9417         return ret_ref;
9418 }
9419
9420 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_ptr) {
9421         LDKFundingLocked this_ptr_conv;
9422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9423         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9424         FundingLocked_free(this_ptr_conv);
9425 }
9426
9427 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
9428         LDKFundingLocked orig_conv;
9429         orig_conv.inner = (void*)(orig & (~1));
9430         orig_conv.is_owned = false;
9431         LDKFundingLocked ret_var = FundingLocked_clone(&orig_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 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
9442         LDKFundingLocked this_ptr_conv;
9443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9444         this_ptr_conv.is_owned = false;
9445         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9446         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
9447         return ret_arr;
9448 }
9449
9450 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9451         LDKFundingLocked this_ptr_conv;
9452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9453         this_ptr_conv.is_owned = false;
9454         LDKThirtyTwoBytes val_ref;
9455         CHECK(*((uint32_t*)val) == 32);
9456         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9457         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
9458 }
9459
9460 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
9461         LDKFundingLocked this_ptr_conv;
9462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9463         this_ptr_conv.is_owned = false;
9464         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9465         memcpy((uint8_t*)(arg_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9466         return arg_arr;
9467 }
9468
9469 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9470         LDKFundingLocked this_ptr_conv;
9471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9472         this_ptr_conv.is_owned = false;
9473         LDKPublicKey val_ref;
9474         CHECK(*((uint32_t*)val) == 33);
9475         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9476         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
9477 }
9478
9479 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
9480         LDKThirtyTwoBytes channel_id_arg_ref;
9481         CHECK(*((uint32_t*)channel_id_arg) == 32);
9482         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9483         LDKPublicKey next_per_commitment_point_arg_ref;
9484         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
9485         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
9486         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
9487         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9488         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9489         long ret_ref = (long)ret_var.inner;
9490         if (ret_var.is_owned) {
9491                 ret_ref |= 1;
9492         }
9493         return ret_ref;
9494 }
9495
9496 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_ptr) {
9497         LDKShutdown this_ptr_conv;
9498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9499         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9500         Shutdown_free(this_ptr_conv);
9501 }
9502
9503 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
9504         LDKShutdown orig_conv;
9505         orig_conv.inner = (void*)(orig & (~1));
9506         orig_conv.is_owned = false;
9507         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
9508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9510         long ret_ref = (long)ret_var.inner;
9511         if (ret_var.is_owned) {
9512                 ret_ref |= 1;
9513         }
9514         return ret_ref;
9515 }
9516
9517 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
9518         LDKShutdown this_ptr_conv;
9519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9520         this_ptr_conv.is_owned = false;
9521         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9522         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
9523         return ret_arr;
9524 }
9525
9526 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9527         LDKShutdown this_ptr_conv;
9528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9529         this_ptr_conv.is_owned = false;
9530         LDKThirtyTwoBytes val_ref;
9531         CHECK(*((uint32_t*)val) == 32);
9532         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9533         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
9534 }
9535
9536 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
9537         LDKShutdown this_ptr_conv;
9538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9539         this_ptr_conv.is_owned = false;
9540         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
9541         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9542         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
9543         return arg_arr;
9544 }
9545
9546 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
9547         LDKShutdown this_ptr_conv;
9548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9549         this_ptr_conv.is_owned = false;
9550         LDKCVec_u8Z val_ref;
9551         val_ref.datalen = *((uint32_t*)val);
9552         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
9553         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
9554         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
9555 }
9556
9557 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
9558         LDKThirtyTwoBytes channel_id_arg_ref;
9559         CHECK(*((uint32_t*)channel_id_arg) == 32);
9560         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9561         LDKCVec_u8Z scriptpubkey_arg_ref;
9562         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
9563         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
9564         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
9565         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
9566         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9567         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9568         long ret_ref = (long)ret_var.inner;
9569         if (ret_var.is_owned) {
9570                 ret_ref |= 1;
9571         }
9572         return ret_ref;
9573 }
9574
9575 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_ptr) {
9576         LDKClosingSigned this_ptr_conv;
9577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9578         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9579         ClosingSigned_free(this_ptr_conv);
9580 }
9581
9582 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
9583         LDKClosingSigned orig_conv;
9584         orig_conv.inner = (void*)(orig & (~1));
9585         orig_conv.is_owned = false;
9586         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
9587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9589         long ret_ref = (long)ret_var.inner;
9590         if (ret_var.is_owned) {
9591                 ret_ref |= 1;
9592         }
9593         return ret_ref;
9594 }
9595
9596 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
9597         LDKClosingSigned this_ptr_conv;
9598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9599         this_ptr_conv.is_owned = false;
9600         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9601         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
9602         return ret_arr;
9603 }
9604
9605 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9606         LDKClosingSigned this_ptr_conv;
9607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9608         this_ptr_conv.is_owned = false;
9609         LDKThirtyTwoBytes val_ref;
9610         CHECK(*((uint32_t*)val) == 32);
9611         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9612         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
9613 }
9614
9615 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
9616         LDKClosingSigned this_ptr_conv;
9617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9618         this_ptr_conv.is_owned = false;
9619         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
9620         return ret_val;
9621 }
9622
9623 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
9624         LDKClosingSigned this_ptr_conv;
9625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9626         this_ptr_conv.is_owned = false;
9627         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
9628 }
9629
9630 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
9631         LDKClosingSigned this_ptr_conv;
9632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9633         this_ptr_conv.is_owned = false;
9634         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9635         memcpy((uint8_t*)(arg_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9636         return arg_arr;
9637 }
9638
9639 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9640         LDKClosingSigned this_ptr_conv;
9641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9642         this_ptr_conv.is_owned = false;
9643         LDKSignature val_ref;
9644         CHECK(*((uint32_t*)val) == 64);
9645         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9646         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
9647 }
9648
9649 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
9650         LDKThirtyTwoBytes channel_id_arg_ref;
9651         CHECK(*((uint32_t*)channel_id_arg) == 32);
9652         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9653         LDKSignature signature_arg_ref;
9654         CHECK(*((uint32_t*)signature_arg) == 64);
9655         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9656         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
9657         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9658         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9659         long ret_ref = (long)ret_var.inner;
9660         if (ret_var.is_owned) {
9661                 ret_ref |= 1;
9662         }
9663         return ret_ref;
9664 }
9665
9666 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_ptr) {
9667         LDKUpdateAddHTLC this_ptr_conv;
9668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9669         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9670         UpdateAddHTLC_free(this_ptr_conv);
9671 }
9672
9673 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
9674         LDKUpdateAddHTLC orig_conv;
9675         orig_conv.inner = (void*)(orig & (~1));
9676         orig_conv.is_owned = false;
9677         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
9678         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9679         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9680         long ret_ref = (long)ret_var.inner;
9681         if (ret_var.is_owned) {
9682                 ret_ref |= 1;
9683         }
9684         return ret_ref;
9685 }
9686
9687 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
9688         LDKUpdateAddHTLC this_ptr_conv;
9689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9690         this_ptr_conv.is_owned = false;
9691         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9692         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
9693         return ret_arr;
9694 }
9695
9696 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9697         LDKUpdateAddHTLC this_ptr_conv;
9698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9699         this_ptr_conv.is_owned = false;
9700         LDKThirtyTwoBytes val_ref;
9701         CHECK(*((uint32_t*)val) == 32);
9702         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9703         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
9704 }
9705
9706 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
9707         LDKUpdateAddHTLC this_ptr_conv;
9708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9709         this_ptr_conv.is_owned = false;
9710         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
9711         return ret_val;
9712 }
9713
9714 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9715         LDKUpdateAddHTLC this_ptr_conv;
9716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9717         this_ptr_conv.is_owned = false;
9718         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
9719 }
9720
9721 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
9722         LDKUpdateAddHTLC this_ptr_conv;
9723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9724         this_ptr_conv.is_owned = false;
9725         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
9726         return ret_val;
9727 }
9728
9729 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
9730         LDKUpdateAddHTLC this_ptr_conv;
9731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9732         this_ptr_conv.is_owned = false;
9733         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
9734 }
9735
9736 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
9737         LDKUpdateAddHTLC this_ptr_conv;
9738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9739         this_ptr_conv.is_owned = false;
9740         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9741         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
9742         return ret_arr;
9743 }
9744
9745 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
9746         LDKUpdateAddHTLC this_ptr_conv;
9747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9748         this_ptr_conv.is_owned = false;
9749         LDKThirtyTwoBytes val_ref;
9750         CHECK(*((uint32_t*)val) == 32);
9751         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9752         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
9753 }
9754
9755 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
9756         LDKUpdateAddHTLC this_ptr_conv;
9757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9758         this_ptr_conv.is_owned = false;
9759         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
9760         return ret_val;
9761 }
9762
9763 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
9764         LDKUpdateAddHTLC this_ptr_conv;
9765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9766         this_ptr_conv.is_owned = false;
9767         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
9768 }
9769
9770 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_ptr) {
9771         LDKUpdateFulfillHTLC this_ptr_conv;
9772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9773         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9774         UpdateFulfillHTLC_free(this_ptr_conv);
9775 }
9776
9777 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
9778         LDKUpdateFulfillHTLC orig_conv;
9779         orig_conv.inner = (void*)(orig & (~1));
9780         orig_conv.is_owned = false;
9781         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
9782         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9783         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9784         long ret_ref = (long)ret_var.inner;
9785         if (ret_var.is_owned) {
9786                 ret_ref |= 1;
9787         }
9788         return ret_ref;
9789 }
9790
9791 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
9792         LDKUpdateFulfillHTLC this_ptr_conv;
9793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9794         this_ptr_conv.is_owned = false;
9795         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9796         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
9797         return ret_arr;
9798 }
9799
9800 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9801         LDKUpdateFulfillHTLC this_ptr_conv;
9802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9803         this_ptr_conv.is_owned = false;
9804         LDKThirtyTwoBytes val_ref;
9805         CHECK(*((uint32_t*)val) == 32);
9806         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9807         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
9808 }
9809
9810 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
9811         LDKUpdateFulfillHTLC this_ptr_conv;
9812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9813         this_ptr_conv.is_owned = false;
9814         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
9815         return ret_val;
9816 }
9817
9818 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9819         LDKUpdateFulfillHTLC this_ptr_conv;
9820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9821         this_ptr_conv.is_owned = false;
9822         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
9823 }
9824
9825 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
9826         LDKUpdateFulfillHTLC this_ptr_conv;
9827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9828         this_ptr_conv.is_owned = false;
9829         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9830         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
9831         return ret_arr;
9832 }
9833
9834 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
9835         LDKUpdateFulfillHTLC this_ptr_conv;
9836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9837         this_ptr_conv.is_owned = false;
9838         LDKThirtyTwoBytes val_ref;
9839         CHECK(*((uint32_t*)val) == 32);
9840         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9841         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
9842 }
9843
9844 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
9845         LDKThirtyTwoBytes channel_id_arg_ref;
9846         CHECK(*((uint32_t*)channel_id_arg) == 32);
9847         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9848         LDKThirtyTwoBytes payment_preimage_arg_ref;
9849         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
9850         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
9851         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
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 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_ptr) {
9862         LDKUpdateFailHTLC this_ptr_conv;
9863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9864         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9865         UpdateFailHTLC_free(this_ptr_conv);
9866 }
9867
9868 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
9869         LDKUpdateFailHTLC orig_conv;
9870         orig_conv.inner = (void*)(orig & (~1));
9871         orig_conv.is_owned = false;
9872         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
9873         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9874         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9875         long ret_ref = (long)ret_var.inner;
9876         if (ret_var.is_owned) {
9877                 ret_ref |= 1;
9878         }
9879         return ret_ref;
9880 }
9881
9882 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
9883         LDKUpdateFailHTLC this_ptr_conv;
9884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9885         this_ptr_conv.is_owned = false;
9886         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9887         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
9888         return ret_arr;
9889 }
9890
9891 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9892         LDKUpdateFailHTLC this_ptr_conv;
9893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9894         this_ptr_conv.is_owned = false;
9895         LDKThirtyTwoBytes val_ref;
9896         CHECK(*((uint32_t*)val) == 32);
9897         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9898         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
9899 }
9900
9901 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
9902         LDKUpdateFailHTLC this_ptr_conv;
9903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9904         this_ptr_conv.is_owned = false;
9905         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
9906         return ret_val;
9907 }
9908
9909 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9910         LDKUpdateFailHTLC this_ptr_conv;
9911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9912         this_ptr_conv.is_owned = false;
9913         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
9914 }
9915
9916 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_ptr) {
9917         LDKUpdateFailMalformedHTLC this_ptr_conv;
9918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9919         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9920         UpdateFailMalformedHTLC_free(this_ptr_conv);
9921 }
9922
9923 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
9924         LDKUpdateFailMalformedHTLC orig_conv;
9925         orig_conv.inner = (void*)(orig & (~1));
9926         orig_conv.is_owned = false;
9927         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
9928         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9929         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9930         long ret_ref = (long)ret_var.inner;
9931         if (ret_var.is_owned) {
9932                 ret_ref |= 1;
9933         }
9934         return ret_ref;
9935 }
9936
9937 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
9938         LDKUpdateFailMalformedHTLC this_ptr_conv;
9939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9940         this_ptr_conv.is_owned = false;
9941         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9942         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
9943         return ret_arr;
9944 }
9945
9946 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9947         LDKUpdateFailMalformedHTLC this_ptr_conv;
9948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9949         this_ptr_conv.is_owned = false;
9950         LDKThirtyTwoBytes val_ref;
9951         CHECK(*((uint32_t*)val) == 32);
9952         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9953         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
9954 }
9955
9956 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
9957         LDKUpdateFailMalformedHTLC this_ptr_conv;
9958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9959         this_ptr_conv.is_owned = false;
9960         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
9961         return ret_val;
9962 }
9963
9964 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9965         LDKUpdateFailMalformedHTLC this_ptr_conv;
9966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9967         this_ptr_conv.is_owned = false;
9968         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
9969 }
9970
9971 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
9972         LDKUpdateFailMalformedHTLC this_ptr_conv;
9973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9974         this_ptr_conv.is_owned = false;
9975         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
9976         return ret_val;
9977 }
9978
9979 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
9980         LDKUpdateFailMalformedHTLC this_ptr_conv;
9981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9982         this_ptr_conv.is_owned = false;
9983         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
9984 }
9985
9986 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_ptr) {
9987         LDKCommitmentSigned this_ptr_conv;
9988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9989         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9990         CommitmentSigned_free(this_ptr_conv);
9991 }
9992
9993 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
9994         LDKCommitmentSigned orig_conv;
9995         orig_conv.inner = (void*)(orig & (~1));
9996         orig_conv.is_owned = false;
9997         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
9998         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9999         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10000         long ret_ref = (long)ret_var.inner;
10001         if (ret_var.is_owned) {
10002                 ret_ref |= 1;
10003         }
10004         return ret_ref;
10005 }
10006
10007 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
10008         LDKCommitmentSigned this_ptr_conv;
10009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10010         this_ptr_conv.is_owned = false;
10011         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10012         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
10013         return ret_arr;
10014 }
10015
10016 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10017         LDKCommitmentSigned this_ptr_conv;
10018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10019         this_ptr_conv.is_owned = false;
10020         LDKThirtyTwoBytes val_ref;
10021         CHECK(*((uint32_t*)val) == 32);
10022         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10023         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
10024 }
10025
10026 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
10027         LDKCommitmentSigned this_ptr_conv;
10028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029         this_ptr_conv.is_owned = false;
10030         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10031         memcpy((uint8_t*)(arg_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
10032         return arg_arr;
10033 }
10034
10035 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
10036         LDKCommitmentSigned this_ptr_conv;
10037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10038         this_ptr_conv.is_owned = false;
10039         LDKSignature val_ref;
10040         CHECK(*((uint32_t*)val) == 64);
10041         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10042         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
10043 }
10044
10045 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
10046         LDKCommitmentSigned this_ptr_conv;
10047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10048         this_ptr_conv.is_owned = false;
10049         LDKCVec_SignatureZ val_constr;
10050         val_constr.datalen = *((uint32_t*)val);
10051         if (val_constr.datalen > 0)
10052                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10053         else
10054                 val_constr.data = NULL;
10055         int8_tArray* val_vals = (int8_tArray*)(val + 4);
10056         for (size_t m = 0; m < val_constr.datalen; m++) {
10057                 int8_tArray arr_conv_12 = val_vals[m];
10058                 LDKSignature arr_conv_12_ref;
10059                 CHECK(*((uint32_t*)arr_conv_12) == 64);
10060                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
10061                 val_constr.data[m] = arr_conv_12_ref;
10062         }
10063         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
10064 }
10065
10066 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
10067         LDKThirtyTwoBytes channel_id_arg_ref;
10068         CHECK(*((uint32_t*)channel_id_arg) == 32);
10069         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10070         LDKSignature signature_arg_ref;
10071         CHECK(*((uint32_t*)signature_arg) == 64);
10072         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10073         LDKCVec_SignatureZ htlc_signatures_arg_constr;
10074         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
10075         if (htlc_signatures_arg_constr.datalen > 0)
10076                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10077         else
10078                 htlc_signatures_arg_constr.data = NULL;
10079         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
10080         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
10081                 int8_tArray arr_conv_12 = htlc_signatures_arg_vals[m];
10082                 LDKSignature arr_conv_12_ref;
10083                 CHECK(*((uint32_t*)arr_conv_12) == 64);
10084                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
10085                 htlc_signatures_arg_constr.data[m] = arr_conv_12_ref;
10086         }
10087         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
10088         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10089         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10090         long ret_ref = (long)ret_var.inner;
10091         if (ret_var.is_owned) {
10092                 ret_ref |= 1;
10093         }
10094         return ret_ref;
10095 }
10096
10097 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_ptr) {
10098         LDKRevokeAndACK this_ptr_conv;
10099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10100         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10101         RevokeAndACK_free(this_ptr_conv);
10102 }
10103
10104 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
10105         LDKRevokeAndACK orig_conv;
10106         orig_conv.inner = (void*)(orig & (~1));
10107         orig_conv.is_owned = false;
10108         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
10109         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10110         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10111         long ret_ref = (long)ret_var.inner;
10112         if (ret_var.is_owned) {
10113                 ret_ref |= 1;
10114         }
10115         return ret_ref;
10116 }
10117
10118 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
10119         LDKRevokeAndACK this_ptr_conv;
10120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10121         this_ptr_conv.is_owned = false;
10122         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10123         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
10124         return ret_arr;
10125 }
10126
10127 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10128         LDKRevokeAndACK this_ptr_conv;
10129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10130         this_ptr_conv.is_owned = false;
10131         LDKThirtyTwoBytes val_ref;
10132         CHECK(*((uint32_t*)val) == 32);
10133         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10134         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
10135 }
10136
10137 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
10138         LDKRevokeAndACK this_ptr_conv;
10139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10140         this_ptr_conv.is_owned = false;
10141         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10142         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
10143         return ret_arr;
10144 }
10145
10146 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10147         LDKRevokeAndACK this_ptr_conv;
10148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10149         this_ptr_conv.is_owned = false;
10150         LDKThirtyTwoBytes val_ref;
10151         CHECK(*((uint32_t*)val) == 32);
10152         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10153         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
10154 }
10155
10156 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
10157         LDKRevokeAndACK this_ptr_conv;
10158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10159         this_ptr_conv.is_owned = false;
10160         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10161         memcpy((uint8_t*)(arg_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10162         return arg_arr;
10163 }
10164
10165 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10166         LDKRevokeAndACK this_ptr_conv;
10167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10168         this_ptr_conv.is_owned = false;
10169         LDKPublicKey val_ref;
10170         CHECK(*((uint32_t*)val) == 33);
10171         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10172         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
10173 }
10174
10175 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) {
10176         LDKThirtyTwoBytes channel_id_arg_ref;
10177         CHECK(*((uint32_t*)channel_id_arg) == 32);
10178         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10179         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
10180         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
10181         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
10182         LDKPublicKey next_per_commitment_point_arg_ref;
10183         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
10184         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
10185         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
10186         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10187         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10188         long ret_ref = (long)ret_var.inner;
10189         if (ret_var.is_owned) {
10190                 ret_ref |= 1;
10191         }
10192         return ret_ref;
10193 }
10194
10195 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_ptr) {
10196         LDKUpdateFee this_ptr_conv;
10197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10198         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10199         UpdateFee_free(this_ptr_conv);
10200 }
10201
10202 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
10203         LDKUpdateFee orig_conv;
10204         orig_conv.inner = (void*)(orig & (~1));
10205         orig_conv.is_owned = false;
10206         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
10207         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10208         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10209         long ret_ref = (long)ret_var.inner;
10210         if (ret_var.is_owned) {
10211                 ret_ref |= 1;
10212         }
10213         return ret_ref;
10214 }
10215
10216 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
10217         LDKUpdateFee this_ptr_conv;
10218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10219         this_ptr_conv.is_owned = false;
10220         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10221         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
10222         return ret_arr;
10223 }
10224
10225 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10226         LDKUpdateFee this_ptr_conv;
10227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10228         this_ptr_conv.is_owned = false;
10229         LDKThirtyTwoBytes val_ref;
10230         CHECK(*((uint32_t*)val) == 32);
10231         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10232         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
10233 }
10234
10235 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
10236         LDKUpdateFee this_ptr_conv;
10237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10238         this_ptr_conv.is_owned = false;
10239         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
10240         return ret_val;
10241 }
10242
10243 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
10244         LDKUpdateFee this_ptr_conv;
10245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10246         this_ptr_conv.is_owned = false;
10247         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
10248 }
10249
10250 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
10251         LDKThirtyTwoBytes channel_id_arg_ref;
10252         CHECK(*((uint32_t*)channel_id_arg) == 32);
10253         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10254         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
10255         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10256         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10257         long ret_ref = (long)ret_var.inner;
10258         if (ret_var.is_owned) {
10259                 ret_ref |= 1;
10260         }
10261         return ret_ref;
10262 }
10263
10264 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_ptr) {
10265         LDKDataLossProtect this_ptr_conv;
10266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10267         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10268         DataLossProtect_free(this_ptr_conv);
10269 }
10270
10271 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
10272         LDKDataLossProtect orig_conv;
10273         orig_conv.inner = (void*)(orig & (~1));
10274         orig_conv.is_owned = false;
10275         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
10276         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10277         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10278         long ret_ref = (long)ret_var.inner;
10279         if (ret_var.is_owned) {
10280                 ret_ref |= 1;
10281         }
10282         return ret_ref;
10283 }
10284
10285 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
10286         LDKDataLossProtect this_ptr_conv;
10287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10288         this_ptr_conv.is_owned = false;
10289         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10290         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
10291         return ret_arr;
10292 }
10293
10294 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10295         LDKDataLossProtect this_ptr_conv;
10296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10297         this_ptr_conv.is_owned = false;
10298         LDKThirtyTwoBytes val_ref;
10299         CHECK(*((uint32_t*)val) == 32);
10300         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10301         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
10302 }
10303
10304 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
10305         LDKDataLossProtect this_ptr_conv;
10306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10307         this_ptr_conv.is_owned = false;
10308         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10309         memcpy((uint8_t*)(arg_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10310         return arg_arr;
10311 }
10312
10313 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10314         LDKDataLossProtect this_ptr_conv;
10315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10316         this_ptr_conv.is_owned = false;
10317         LDKPublicKey val_ref;
10318         CHECK(*((uint32_t*)val) == 33);
10319         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10320         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
10321 }
10322
10323 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
10324         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
10325         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
10326         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
10327         LDKPublicKey my_current_per_commitment_point_arg_ref;
10328         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
10329         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
10330         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
10331         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10332         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10333         long ret_ref = (long)ret_var.inner;
10334         if (ret_var.is_owned) {
10335                 ret_ref |= 1;
10336         }
10337         return ret_ref;
10338 }
10339
10340 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_ptr) {
10341         LDKChannelReestablish this_ptr_conv;
10342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10343         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10344         ChannelReestablish_free(this_ptr_conv);
10345 }
10346
10347 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
10348         LDKChannelReestablish orig_conv;
10349         orig_conv.inner = (void*)(orig & (~1));
10350         orig_conv.is_owned = false;
10351         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
10352         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10353         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10354         long ret_ref = (long)ret_var.inner;
10355         if (ret_var.is_owned) {
10356                 ret_ref |= 1;
10357         }
10358         return ret_ref;
10359 }
10360
10361 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
10362         LDKChannelReestablish this_ptr_conv;
10363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10364         this_ptr_conv.is_owned = false;
10365         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10366         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
10367         return ret_arr;
10368 }
10369
10370 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10371         LDKChannelReestablish this_ptr_conv;
10372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10373         this_ptr_conv.is_owned = false;
10374         LDKThirtyTwoBytes val_ref;
10375         CHECK(*((uint32_t*)val) == 32);
10376         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10377         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
10378 }
10379
10380 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
10381         LDKChannelReestablish this_ptr_conv;
10382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10383         this_ptr_conv.is_owned = false;
10384         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
10385         return ret_val;
10386 }
10387
10388 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
10389         LDKChannelReestablish this_ptr_conv;
10390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10391         this_ptr_conv.is_owned = false;
10392         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
10393 }
10394
10395 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
10396         LDKChannelReestablish this_ptr_conv;
10397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10398         this_ptr_conv.is_owned = false;
10399         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
10400         return ret_val;
10401 }
10402
10403 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
10404         LDKChannelReestablish this_ptr_conv;
10405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10406         this_ptr_conv.is_owned = false;
10407         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
10408 }
10409
10410 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_ptr) {
10411         LDKAnnouncementSignatures this_ptr_conv;
10412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10413         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10414         AnnouncementSignatures_free(this_ptr_conv);
10415 }
10416
10417 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
10418         LDKAnnouncementSignatures orig_conv;
10419         orig_conv.inner = (void*)(orig & (~1));
10420         orig_conv.is_owned = false;
10421         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
10422         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10423         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10424         long ret_ref = (long)ret_var.inner;
10425         if (ret_var.is_owned) {
10426                 ret_ref |= 1;
10427         }
10428         return ret_ref;
10429 }
10430
10431 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
10432         LDKAnnouncementSignatures this_ptr_conv;
10433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10434         this_ptr_conv.is_owned = false;
10435         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10436         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
10437         return ret_arr;
10438 }
10439
10440 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10441         LDKAnnouncementSignatures this_ptr_conv;
10442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10443         this_ptr_conv.is_owned = false;
10444         LDKThirtyTwoBytes val_ref;
10445         CHECK(*((uint32_t*)val) == 32);
10446         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10447         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
10448 }
10449
10450 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
10451         LDKAnnouncementSignatures this_ptr_conv;
10452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10453         this_ptr_conv.is_owned = false;
10454         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
10455         return ret_val;
10456 }
10457
10458 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10459         LDKAnnouncementSignatures this_ptr_conv;
10460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10461         this_ptr_conv.is_owned = false;
10462         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
10463 }
10464
10465 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
10466         LDKAnnouncementSignatures this_ptr_conv;
10467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10468         this_ptr_conv.is_owned = false;
10469         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10470         memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
10471         return arg_arr;
10472 }
10473
10474 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
10475         LDKAnnouncementSignatures this_ptr_conv;
10476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10477         this_ptr_conv.is_owned = false;
10478         LDKSignature val_ref;
10479         CHECK(*((uint32_t*)val) == 64);
10480         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10481         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
10482 }
10483
10484 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
10485         LDKAnnouncementSignatures this_ptr_conv;
10486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10487         this_ptr_conv.is_owned = false;
10488         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10489         memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
10490         return arg_arr;
10491 }
10492
10493 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
10494         LDKAnnouncementSignatures this_ptr_conv;
10495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10496         this_ptr_conv.is_owned = false;
10497         LDKSignature val_ref;
10498         CHECK(*((uint32_t*)val) == 64);
10499         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10500         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
10501 }
10502
10503 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) {
10504         LDKThirtyTwoBytes channel_id_arg_ref;
10505         CHECK(*((uint32_t*)channel_id_arg) == 32);
10506         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10507         LDKSignature node_signature_arg_ref;
10508         CHECK(*((uint32_t*)node_signature_arg) == 64);
10509         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
10510         LDKSignature bitcoin_signature_arg_ref;
10511         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
10512         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
10513         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
10514         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10515         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10516         long ret_ref = (long)ret_var.inner;
10517         if (ret_var.is_owned) {
10518                 ret_ref |= 1;
10519         }
10520         return ret_ref;
10521 }
10522
10523 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
10524         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
10525         FREE((void*)this_ptr);
10526         NetAddress_free(this_ptr_conv);
10527 }
10528
10529 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
10530         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
10531         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10532         *ret_copy = NetAddress_clone(orig_conv);
10533         long ret_ref = (long)ret_copy;
10534         return ret_ref;
10535 }
10536
10537 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
10538         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
10539         LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
10540         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10541         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
10542         CVec_u8Z_free(arg_var);
10543         return arg_arr;
10544 }
10545
10546 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
10547         LDKu8slice ser_ref;
10548         ser_ref.datalen = *((uint32_t*)ser);
10549         ser_ref.data = (int8_t*)(ser + 4);
10550         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10551         *ret_conv = Result_read(ser_ref);
10552         return (long)ret_conv;
10553 }
10554
10555 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_ptr) {
10556         LDKUnsignedNodeAnnouncement this_ptr_conv;
10557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10559         UnsignedNodeAnnouncement_free(this_ptr_conv);
10560 }
10561
10562 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
10563         LDKUnsignedNodeAnnouncement orig_conv;
10564         orig_conv.inner = (void*)(orig & (~1));
10565         orig_conv.is_owned = false;
10566         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
10567         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10568         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10569         long ret_ref = (long)ret_var.inner;
10570         if (ret_var.is_owned) {
10571                 ret_ref |= 1;
10572         }
10573         return ret_ref;
10574 }
10575
10576 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
10577         LDKUnsignedNodeAnnouncement this_ptr_conv;
10578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10579         this_ptr_conv.is_owned = false;
10580         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
10581         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10582         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10583         long ret_ref = (long)ret_var.inner;
10584         if (ret_var.is_owned) {
10585                 ret_ref |= 1;
10586         }
10587         return ret_ref;
10588 }
10589
10590 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10591         LDKUnsignedNodeAnnouncement this_ptr_conv;
10592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10593         this_ptr_conv.is_owned = false;
10594         LDKNodeFeatures val_conv;
10595         val_conv.inner = (void*)(val & (~1));
10596         val_conv.is_owned = (val & 1) || (val == 0);
10597         // Warning: we may need a move here but can't clone!
10598         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
10599 }
10600
10601 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
10602         LDKUnsignedNodeAnnouncement this_ptr_conv;
10603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10604         this_ptr_conv.is_owned = false;
10605         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
10606         return ret_val;
10607 }
10608
10609 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
10610         LDKUnsignedNodeAnnouncement this_ptr_conv;
10611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10612         this_ptr_conv.is_owned = false;
10613         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
10614 }
10615
10616 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
10617         LDKUnsignedNodeAnnouncement this_ptr_conv;
10618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10619         this_ptr_conv.is_owned = false;
10620         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10621         memcpy((uint8_t*)(arg_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
10622         return arg_arr;
10623 }
10624
10625 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
10626         LDKUnsignedNodeAnnouncement this_ptr_conv;
10627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10628         this_ptr_conv.is_owned = false;
10629         LDKPublicKey val_ref;
10630         CHECK(*((uint32_t*)val) == 33);
10631         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10632         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
10633 }
10634
10635 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
10636         LDKUnsignedNodeAnnouncement this_ptr_conv;
10637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10638         this_ptr_conv.is_owned = false;
10639         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
10640         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
10641         return ret_arr;
10642 }
10643
10644 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
10645         LDKUnsignedNodeAnnouncement this_ptr_conv;
10646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10647         this_ptr_conv.is_owned = false;
10648         LDKThreeBytes val_ref;
10649         CHECK(*((uint32_t*)val) == 3);
10650         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
10651         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
10652 }
10653
10654 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
10655         LDKUnsignedNodeAnnouncement this_ptr_conv;
10656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10657         this_ptr_conv.is_owned = false;
10658         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10659         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
10660         return ret_arr;
10661 }
10662
10663 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
10664         LDKUnsignedNodeAnnouncement this_ptr_conv;
10665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10666         this_ptr_conv.is_owned = false;
10667         LDKThirtyTwoBytes val_ref;
10668         CHECK(*((uint32_t*)val) == 32);
10669         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10670         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
10671 }
10672
10673 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
10674         LDKUnsignedNodeAnnouncement this_ptr_conv;
10675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10676         this_ptr_conv.is_owned = false;
10677         LDKCVec_NetAddressZ val_constr;
10678         val_constr.datalen = *((uint32_t*)val);
10679         if (val_constr.datalen > 0)
10680                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10681         else
10682                 val_constr.data = NULL;
10683         uint32_t* val_vals = (uint32_t*)(val + 4);
10684         for (size_t m = 0; m < val_constr.datalen; m++) {
10685                 uint32_t arr_conv_12 = val_vals[m];
10686                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
10687                 FREE((void*)arr_conv_12);
10688                 val_constr.data[m] = arr_conv_12_conv;
10689         }
10690         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
10691 }
10692
10693 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_ptr) {
10694         LDKNodeAnnouncement this_ptr_conv;
10695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10696         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10697         NodeAnnouncement_free(this_ptr_conv);
10698 }
10699
10700 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
10701         LDKNodeAnnouncement orig_conv;
10702         orig_conv.inner = (void*)(orig & (~1));
10703         orig_conv.is_owned = false;
10704         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
10705         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10706         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10707         long ret_ref = (long)ret_var.inner;
10708         if (ret_var.is_owned) {
10709                 ret_ref |= 1;
10710         }
10711         return ret_ref;
10712 }
10713
10714 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
10715         LDKNodeAnnouncement this_ptr_conv;
10716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10717         this_ptr_conv.is_owned = false;
10718         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10719         memcpy((uint8_t*)(arg_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
10720         return arg_arr;
10721 }
10722
10723 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
10724         LDKNodeAnnouncement this_ptr_conv;
10725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10726         this_ptr_conv.is_owned = false;
10727         LDKSignature val_ref;
10728         CHECK(*((uint32_t*)val) == 64);
10729         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10730         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
10731 }
10732
10733 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
10734         LDKNodeAnnouncement this_ptr_conv;
10735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10736         this_ptr_conv.is_owned = false;
10737         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
10738         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10739         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10740         long ret_ref = (long)ret_var.inner;
10741         if (ret_var.is_owned) {
10742                 ret_ref |= 1;
10743         }
10744         return ret_ref;
10745 }
10746
10747 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
10748         LDKNodeAnnouncement this_ptr_conv;
10749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10750         this_ptr_conv.is_owned = false;
10751         LDKUnsignedNodeAnnouncement val_conv;
10752         val_conv.inner = (void*)(val & (~1));
10753         val_conv.is_owned = (val & 1) || (val == 0);
10754         if (val_conv.inner != NULL)
10755                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
10756         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
10757 }
10758
10759 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
10760         LDKSignature signature_arg_ref;
10761         CHECK(*((uint32_t*)signature_arg) == 64);
10762         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10763         LDKUnsignedNodeAnnouncement contents_arg_conv;
10764         contents_arg_conv.inner = (void*)(contents_arg & (~1));
10765         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
10766         if (contents_arg_conv.inner != NULL)
10767                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
10768         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
10769         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10770         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10771         long ret_ref = (long)ret_var.inner;
10772         if (ret_var.is_owned) {
10773                 ret_ref |= 1;
10774         }
10775         return ret_ref;
10776 }
10777
10778 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_ptr) {
10779         LDKUnsignedChannelAnnouncement this_ptr_conv;
10780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10781         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10782         UnsignedChannelAnnouncement_free(this_ptr_conv);
10783 }
10784
10785 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
10786         LDKUnsignedChannelAnnouncement orig_conv;
10787         orig_conv.inner = (void*)(orig & (~1));
10788         orig_conv.is_owned = false;
10789         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
10790         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10791         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10792         long ret_ref = (long)ret_var.inner;
10793         if (ret_var.is_owned) {
10794                 ret_ref |= 1;
10795         }
10796         return ret_ref;
10797 }
10798
10799 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
10800         LDKUnsignedChannelAnnouncement this_ptr_conv;
10801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10802         this_ptr_conv.is_owned = false;
10803         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
10804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10806         long ret_ref = (long)ret_var.inner;
10807         if (ret_var.is_owned) {
10808                 ret_ref |= 1;
10809         }
10810         return ret_ref;
10811 }
10812
10813 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10814         LDKUnsignedChannelAnnouncement this_ptr_conv;
10815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10816         this_ptr_conv.is_owned = false;
10817         LDKChannelFeatures val_conv;
10818         val_conv.inner = (void*)(val & (~1));
10819         val_conv.is_owned = (val & 1) || (val == 0);
10820         // Warning: we may need a move here but can't clone!
10821         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
10822 }
10823
10824 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
10825         LDKUnsignedChannelAnnouncement this_ptr_conv;
10826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10827         this_ptr_conv.is_owned = false;
10828         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10829         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
10830         return ret_arr;
10831 }
10832
10833 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
10834         LDKUnsignedChannelAnnouncement this_ptr_conv;
10835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10836         this_ptr_conv.is_owned = false;
10837         LDKThirtyTwoBytes val_ref;
10838         CHECK(*((uint32_t*)val) == 32);
10839         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10840         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
10841 }
10842
10843 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
10844         LDKUnsignedChannelAnnouncement this_ptr_conv;
10845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10846         this_ptr_conv.is_owned = false;
10847         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
10848         return ret_val;
10849 }
10850
10851 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10852         LDKUnsignedChannelAnnouncement this_ptr_conv;
10853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10854         this_ptr_conv.is_owned = false;
10855         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
10856 }
10857
10858 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
10859         LDKUnsignedChannelAnnouncement this_ptr_conv;
10860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10861         this_ptr_conv.is_owned = false;
10862         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10863         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
10864         return arg_arr;
10865 }
10866
10867 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
10868         LDKUnsignedChannelAnnouncement this_ptr_conv;
10869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10870         this_ptr_conv.is_owned = false;
10871         LDKPublicKey val_ref;
10872         CHECK(*((uint32_t*)val) == 33);
10873         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10874         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
10875 }
10876
10877 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
10878         LDKUnsignedChannelAnnouncement this_ptr_conv;
10879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10880         this_ptr_conv.is_owned = false;
10881         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10882         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
10883         return arg_arr;
10884 }
10885
10886 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
10887         LDKUnsignedChannelAnnouncement this_ptr_conv;
10888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10889         this_ptr_conv.is_owned = false;
10890         LDKPublicKey val_ref;
10891         CHECK(*((uint32_t*)val) == 33);
10892         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10893         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
10894 }
10895
10896 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
10897         LDKUnsignedChannelAnnouncement this_ptr_conv;
10898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10899         this_ptr_conv.is_owned = false;
10900         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10901         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
10902         return arg_arr;
10903 }
10904
10905 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
10906         LDKUnsignedChannelAnnouncement this_ptr_conv;
10907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10908         this_ptr_conv.is_owned = false;
10909         LDKPublicKey val_ref;
10910         CHECK(*((uint32_t*)val) == 33);
10911         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10912         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
10913 }
10914
10915 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
10916         LDKUnsignedChannelAnnouncement this_ptr_conv;
10917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10918         this_ptr_conv.is_owned = false;
10919         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10920         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
10921         return arg_arr;
10922 }
10923
10924 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
10925         LDKUnsignedChannelAnnouncement this_ptr_conv;
10926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10927         this_ptr_conv.is_owned = false;
10928         LDKPublicKey val_ref;
10929         CHECK(*((uint32_t*)val) == 33);
10930         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10931         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
10932 }
10933
10934 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_ptr) {
10935         LDKChannelAnnouncement this_ptr_conv;
10936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10937         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10938         ChannelAnnouncement_free(this_ptr_conv);
10939 }
10940
10941 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
10942         LDKChannelAnnouncement orig_conv;
10943         orig_conv.inner = (void*)(orig & (~1));
10944         orig_conv.is_owned = false;
10945         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
10946         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10947         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10948         long ret_ref = (long)ret_var.inner;
10949         if (ret_var.is_owned) {
10950                 ret_ref |= 1;
10951         }
10952         return ret_ref;
10953 }
10954
10955 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
10956         LDKChannelAnnouncement this_ptr_conv;
10957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10958         this_ptr_conv.is_owned = false;
10959         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10960         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
10961         return arg_arr;
10962 }
10963
10964 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
10965         LDKChannelAnnouncement this_ptr_conv;
10966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10967         this_ptr_conv.is_owned = false;
10968         LDKSignature val_ref;
10969         CHECK(*((uint32_t*)val) == 64);
10970         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10971         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
10972 }
10973
10974 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
10975         LDKChannelAnnouncement this_ptr_conv;
10976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10977         this_ptr_conv.is_owned = false;
10978         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10979         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
10980         return arg_arr;
10981 }
10982
10983 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
10984         LDKChannelAnnouncement this_ptr_conv;
10985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10986         this_ptr_conv.is_owned = false;
10987         LDKSignature val_ref;
10988         CHECK(*((uint32_t*)val) == 64);
10989         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10990         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
10991 }
10992
10993 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
10994         LDKChannelAnnouncement this_ptr_conv;
10995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10996         this_ptr_conv.is_owned = false;
10997         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10998         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
10999         return arg_arr;
11000 }
11001
11002 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
11003         LDKChannelAnnouncement this_ptr_conv;
11004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11005         this_ptr_conv.is_owned = false;
11006         LDKSignature val_ref;
11007         CHECK(*((uint32_t*)val) == 64);
11008         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
11009         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
11010 }
11011
11012 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
11013         LDKChannelAnnouncement this_ptr_conv;
11014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11015         this_ptr_conv.is_owned = false;
11016         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
11017         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
11018         return arg_arr;
11019 }
11020
11021 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
11022         LDKChannelAnnouncement this_ptr_conv;
11023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11024         this_ptr_conv.is_owned = false;
11025         LDKSignature val_ref;
11026         CHECK(*((uint32_t*)val) == 64);
11027         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
11028         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
11029 }
11030
11031 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
11032         LDKChannelAnnouncement this_ptr_conv;
11033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11034         this_ptr_conv.is_owned = false;
11035         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
11036         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11037         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11038         long ret_ref = (long)ret_var.inner;
11039         if (ret_var.is_owned) {
11040                 ret_ref |= 1;
11041         }
11042         return ret_ref;
11043 }
11044
11045 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
11046         LDKChannelAnnouncement this_ptr_conv;
11047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11048         this_ptr_conv.is_owned = false;
11049         LDKUnsignedChannelAnnouncement val_conv;
11050         val_conv.inner = (void*)(val & (~1));
11051         val_conv.is_owned = (val & 1) || (val == 0);
11052         if (val_conv.inner != NULL)
11053                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
11054         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
11055 }
11056
11057 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) {
11058         LDKSignature node_signature_1_arg_ref;
11059         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
11060         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
11061         LDKSignature node_signature_2_arg_ref;
11062         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
11063         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
11064         LDKSignature bitcoin_signature_1_arg_ref;
11065         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
11066         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
11067         LDKSignature bitcoin_signature_2_arg_ref;
11068         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
11069         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
11070         LDKUnsignedChannelAnnouncement contents_arg_conv;
11071         contents_arg_conv.inner = (void*)(contents_arg & (~1));
11072         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11073         if (contents_arg_conv.inner != NULL)
11074                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
11075         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);
11076         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11077         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11078         long ret_ref = (long)ret_var.inner;
11079         if (ret_var.is_owned) {
11080                 ret_ref |= 1;
11081         }
11082         return ret_ref;
11083 }
11084
11085 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_ptr) {
11086         LDKUnsignedChannelUpdate this_ptr_conv;
11087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11088         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11089         UnsignedChannelUpdate_free(this_ptr_conv);
11090 }
11091
11092 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
11093         LDKUnsignedChannelUpdate orig_conv;
11094         orig_conv.inner = (void*)(orig & (~1));
11095         orig_conv.is_owned = false;
11096         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
11097         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11098         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11099         long ret_ref = (long)ret_var.inner;
11100         if (ret_var.is_owned) {
11101                 ret_ref |= 1;
11102         }
11103         return ret_ref;
11104 }
11105
11106 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
11107         LDKUnsignedChannelUpdate this_ptr_conv;
11108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11109         this_ptr_conv.is_owned = false;
11110         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11111         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
11112         return ret_arr;
11113 }
11114
11115 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11116         LDKUnsignedChannelUpdate this_ptr_conv;
11117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11118         this_ptr_conv.is_owned = false;
11119         LDKThirtyTwoBytes val_ref;
11120         CHECK(*((uint32_t*)val) == 32);
11121         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11122         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
11123 }
11124
11125 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
11126         LDKUnsignedChannelUpdate this_ptr_conv;
11127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11128         this_ptr_conv.is_owned = false;
11129         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
11130         return ret_val;
11131 }
11132
11133 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
11134         LDKUnsignedChannelUpdate this_ptr_conv;
11135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11136         this_ptr_conv.is_owned = false;
11137         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
11138 }
11139
11140 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
11141         LDKUnsignedChannelUpdate this_ptr_conv;
11142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11143         this_ptr_conv.is_owned = false;
11144         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
11145         return ret_val;
11146 }
11147
11148 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
11149         LDKUnsignedChannelUpdate this_ptr_conv;
11150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11151         this_ptr_conv.is_owned = false;
11152         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
11153 }
11154
11155 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
11156         LDKUnsignedChannelUpdate this_ptr_conv;
11157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11158         this_ptr_conv.is_owned = false;
11159         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
11160         return ret_val;
11161 }
11162
11163 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
11164         LDKUnsignedChannelUpdate this_ptr_conv;
11165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11166         this_ptr_conv.is_owned = false;
11167         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
11168 }
11169
11170 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
11171         LDKUnsignedChannelUpdate this_ptr_conv;
11172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11173         this_ptr_conv.is_owned = false;
11174         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
11175         return ret_val;
11176 }
11177
11178 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11179         LDKUnsignedChannelUpdate this_ptr_conv;
11180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11181         this_ptr_conv.is_owned = false;
11182         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
11183 }
11184
11185 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
11186         LDKUnsignedChannelUpdate this_ptr_conv;
11187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11188         this_ptr_conv.is_owned = false;
11189         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
11190         return ret_val;
11191 }
11192
11193 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11194         LDKUnsignedChannelUpdate this_ptr_conv;
11195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11196         this_ptr_conv.is_owned = false;
11197         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
11198 }
11199
11200 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
11201         LDKUnsignedChannelUpdate this_ptr_conv;
11202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11203         this_ptr_conv.is_owned = false;
11204         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
11205         return ret_val;
11206 }
11207
11208 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
11209         LDKUnsignedChannelUpdate this_ptr_conv;
11210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11211         this_ptr_conv.is_owned = false;
11212         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
11213 }
11214
11215 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
11216         LDKUnsignedChannelUpdate this_ptr_conv;
11217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11218         this_ptr_conv.is_owned = false;
11219         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
11220         return ret_val;
11221 }
11222
11223 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11224         LDKUnsignedChannelUpdate this_ptr_conv;
11225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11226         this_ptr_conv.is_owned = false;
11227         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
11228 }
11229
11230 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_ptr) {
11231         LDKChannelUpdate this_ptr_conv;
11232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11233         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11234         ChannelUpdate_free(this_ptr_conv);
11235 }
11236
11237 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
11238         LDKChannelUpdate orig_conv;
11239         orig_conv.inner = (void*)(orig & (~1));
11240         orig_conv.is_owned = false;
11241         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
11242         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11243         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11244         long ret_ref = (long)ret_var.inner;
11245         if (ret_var.is_owned) {
11246                 ret_ref |= 1;
11247         }
11248         return ret_ref;
11249 }
11250
11251 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
11252         LDKChannelUpdate this_ptr_conv;
11253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11254         this_ptr_conv.is_owned = false;
11255         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
11256         memcpy((uint8_t*)(arg_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
11257         return arg_arr;
11258 }
11259
11260 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
11261         LDKChannelUpdate this_ptr_conv;
11262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11263         this_ptr_conv.is_owned = false;
11264         LDKSignature val_ref;
11265         CHECK(*((uint32_t*)val) == 64);
11266         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
11267         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
11268 }
11269
11270 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
11271         LDKChannelUpdate this_ptr_conv;
11272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11273         this_ptr_conv.is_owned = false;
11274         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
11275         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11276         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11277         long ret_ref = (long)ret_var.inner;
11278         if (ret_var.is_owned) {
11279                 ret_ref |= 1;
11280         }
11281         return ret_ref;
11282 }
11283
11284 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
11285         LDKChannelUpdate this_ptr_conv;
11286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11287         this_ptr_conv.is_owned = false;
11288         LDKUnsignedChannelUpdate val_conv;
11289         val_conv.inner = (void*)(val & (~1));
11290         val_conv.is_owned = (val & 1) || (val == 0);
11291         if (val_conv.inner != NULL)
11292                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
11293         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
11294 }
11295
11296 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
11297         LDKSignature signature_arg_ref;
11298         CHECK(*((uint32_t*)signature_arg) == 64);
11299         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
11300         LDKUnsignedChannelUpdate contents_arg_conv;
11301         contents_arg_conv.inner = (void*)(contents_arg & (~1));
11302         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11303         if (contents_arg_conv.inner != NULL)
11304                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
11305         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
11306         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11307         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11308         long ret_ref = (long)ret_var.inner;
11309         if (ret_var.is_owned) {
11310                 ret_ref |= 1;
11311         }
11312         return ret_ref;
11313 }
11314
11315 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_ptr) {
11316         LDKQueryChannelRange this_ptr_conv;
11317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11318         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11319         QueryChannelRange_free(this_ptr_conv);
11320 }
11321
11322 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
11323         LDKQueryChannelRange orig_conv;
11324         orig_conv.inner = (void*)(orig & (~1));
11325         orig_conv.is_owned = false;
11326         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
11327         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11328         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11329         long ret_ref = (long)ret_var.inner;
11330         if (ret_var.is_owned) {
11331                 ret_ref |= 1;
11332         }
11333         return ret_ref;
11334 }
11335
11336 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
11337         LDKQueryChannelRange this_ptr_conv;
11338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11339         this_ptr_conv.is_owned = false;
11340         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11341         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
11342         return ret_arr;
11343 }
11344
11345 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11346         LDKQueryChannelRange this_ptr_conv;
11347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11348         this_ptr_conv.is_owned = false;
11349         LDKThirtyTwoBytes val_ref;
11350         CHECK(*((uint32_t*)val) == 32);
11351         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11352         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11353 }
11354
11355 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
11356         LDKQueryChannelRange this_ptr_conv;
11357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11358         this_ptr_conv.is_owned = false;
11359         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
11360         return ret_val;
11361 }
11362
11363 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11364         LDKQueryChannelRange this_ptr_conv;
11365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11366         this_ptr_conv.is_owned = false;
11367         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
11368 }
11369
11370 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11371         LDKQueryChannelRange this_ptr_conv;
11372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11373         this_ptr_conv.is_owned = false;
11374         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
11375         return ret_val;
11376 }
11377
11378 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11379         LDKQueryChannelRange this_ptr_conv;
11380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11381         this_ptr_conv.is_owned = false;
11382         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11383 }
11384
11385 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
11386         LDKThirtyTwoBytes chain_hash_arg_ref;
11387         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11388         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11389         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
11390         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11391         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11392         long ret_ref = (long)ret_var.inner;
11393         if (ret_var.is_owned) {
11394                 ret_ref |= 1;
11395         }
11396         return ret_ref;
11397 }
11398
11399 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_ptr) {
11400         LDKReplyChannelRange this_ptr_conv;
11401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11402         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11403         ReplyChannelRange_free(this_ptr_conv);
11404 }
11405
11406 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
11407         LDKReplyChannelRange orig_conv;
11408         orig_conv.inner = (void*)(orig & (~1));
11409         orig_conv.is_owned = false;
11410         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
11411         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11412         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11413         long ret_ref = (long)ret_var.inner;
11414         if (ret_var.is_owned) {
11415                 ret_ref |= 1;
11416         }
11417         return ret_ref;
11418 }
11419
11420 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
11421         LDKReplyChannelRange this_ptr_conv;
11422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11423         this_ptr_conv.is_owned = false;
11424         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11425         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
11426         return ret_arr;
11427 }
11428
11429 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11430         LDKReplyChannelRange this_ptr_conv;
11431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11432         this_ptr_conv.is_owned = false;
11433         LDKThirtyTwoBytes val_ref;
11434         CHECK(*((uint32_t*)val) == 32);
11435         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11436         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11437 }
11438
11439 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
11440         LDKReplyChannelRange this_ptr_conv;
11441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11442         this_ptr_conv.is_owned = false;
11443         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
11444         return ret_val;
11445 }
11446
11447 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11448         LDKReplyChannelRange this_ptr_conv;
11449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11450         this_ptr_conv.is_owned = false;
11451         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
11452 }
11453
11454 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11455         LDKReplyChannelRange this_ptr_conv;
11456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11457         this_ptr_conv.is_owned = false;
11458         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
11459         return ret_val;
11460 }
11461
11462 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11463         LDKReplyChannelRange this_ptr_conv;
11464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11465         this_ptr_conv.is_owned = false;
11466         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11467 }
11468
11469 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_full_information(uint32_t this_ptr) {
11470         LDKReplyChannelRange this_ptr_conv;
11471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11472         this_ptr_conv.is_owned = false;
11473         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
11474         return ret_val;
11475 }
11476
11477 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_full_information(uint32_t this_ptr, jboolean val) {
11478         LDKReplyChannelRange this_ptr_conv;
11479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11480         this_ptr_conv.is_owned = false;
11481         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
11482 }
11483
11484 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11485         LDKReplyChannelRange this_ptr_conv;
11486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11487         this_ptr_conv.is_owned = false;
11488         LDKCVec_u64Z val_constr;
11489         val_constr.datalen = *((uint32_t*)val);
11490         if (val_constr.datalen > 0)
11491                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11492         else
11493                 val_constr.data = NULL;
11494         int64_t* val_vals = (int64_t*)(val + 4);
11495         for (size_t i = 0; i < val_constr.datalen; i++) {
11496                 int64_t arr_conv_8 = val_vals[i];
11497                 val_constr.data[i] = arr_conv_8;
11498         }
11499         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
11500 }
11501
11502 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 full_information_arg, int64_tArray short_channel_ids_arg) {
11503         LDKThirtyTwoBytes chain_hash_arg_ref;
11504         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11505         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11506         LDKCVec_u64Z short_channel_ids_arg_constr;
11507         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11508         if (short_channel_ids_arg_constr.datalen > 0)
11509                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11510         else
11511                 short_channel_ids_arg_constr.data = NULL;
11512         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11513         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11514                 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11515                 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11516         }
11517         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
11518         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11519         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11520         long ret_ref = (long)ret_var.inner;
11521         if (ret_var.is_owned) {
11522                 ret_ref |= 1;
11523         }
11524         return ret_ref;
11525 }
11526
11527 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_ptr) {
11528         LDKQueryShortChannelIds this_ptr_conv;
11529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11531         QueryShortChannelIds_free(this_ptr_conv);
11532 }
11533
11534 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
11535         LDKQueryShortChannelIds orig_conv;
11536         orig_conv.inner = (void*)(orig & (~1));
11537         orig_conv.is_owned = false;
11538         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
11539         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11540         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11541         long ret_ref = (long)ret_var.inner;
11542         if (ret_var.is_owned) {
11543                 ret_ref |= 1;
11544         }
11545         return ret_ref;
11546 }
11547
11548 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
11549         LDKQueryShortChannelIds this_ptr_conv;
11550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11551         this_ptr_conv.is_owned = false;
11552         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11553         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
11554         return ret_arr;
11555 }
11556
11557 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11558         LDKQueryShortChannelIds this_ptr_conv;
11559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11560         this_ptr_conv.is_owned = false;
11561         LDKThirtyTwoBytes val_ref;
11562         CHECK(*((uint32_t*)val) == 32);
11563         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11564         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
11565 }
11566
11567 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11568         LDKQueryShortChannelIds this_ptr_conv;
11569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11570         this_ptr_conv.is_owned = false;
11571         LDKCVec_u64Z val_constr;
11572         val_constr.datalen = *((uint32_t*)val);
11573         if (val_constr.datalen > 0)
11574                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11575         else
11576                 val_constr.data = NULL;
11577         int64_t* val_vals = (int64_t*)(val + 4);
11578         for (size_t i = 0; i < val_constr.datalen; i++) {
11579                 int64_t arr_conv_8 = val_vals[i];
11580                 val_constr.data[i] = arr_conv_8;
11581         }
11582         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
11583 }
11584
11585 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
11586         LDKThirtyTwoBytes chain_hash_arg_ref;
11587         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11588         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11589         LDKCVec_u64Z short_channel_ids_arg_constr;
11590         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11591         if (short_channel_ids_arg_constr.datalen > 0)
11592                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11593         else
11594                 short_channel_ids_arg_constr.data = NULL;
11595         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11596         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11597                 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11598                 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11599         }
11600         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
11601         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11602         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11603         long ret_ref = (long)ret_var.inner;
11604         if (ret_var.is_owned) {
11605                 ret_ref |= 1;
11606         }
11607         return ret_ref;
11608 }
11609
11610 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_ptr) {
11611         LDKReplyShortChannelIdsEnd this_ptr_conv;
11612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11614         ReplyShortChannelIdsEnd_free(this_ptr_conv);
11615 }
11616
11617 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
11618         LDKReplyShortChannelIdsEnd orig_conv;
11619         orig_conv.inner = (void*)(orig & (~1));
11620         orig_conv.is_owned = false;
11621         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
11622         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11623         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11624         long ret_ref = (long)ret_var.inner;
11625         if (ret_var.is_owned) {
11626                 ret_ref |= 1;
11627         }
11628         return ret_ref;
11629 }
11630
11631 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
11632         LDKReplyShortChannelIdsEnd this_ptr_conv;
11633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11634         this_ptr_conv.is_owned = false;
11635         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11636         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
11637         return ret_arr;
11638 }
11639
11640 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11641         LDKReplyShortChannelIdsEnd this_ptr_conv;
11642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11643         this_ptr_conv.is_owned = false;
11644         LDKThirtyTwoBytes val_ref;
11645         CHECK(*((uint32_t*)val) == 32);
11646         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11647         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
11648 }
11649
11650 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
11651         LDKReplyShortChannelIdsEnd this_ptr_conv;
11652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11653         this_ptr_conv.is_owned = false;
11654         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
11655         return ret_val;
11656 }
11657
11658 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
11659         LDKReplyShortChannelIdsEnd this_ptr_conv;
11660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11661         this_ptr_conv.is_owned = false;
11662         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
11663 }
11664
11665 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
11666         LDKThirtyTwoBytes chain_hash_arg_ref;
11667         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11668         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11669         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
11670         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11671         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11672         long ret_ref = (long)ret_var.inner;
11673         if (ret_var.is_owned) {
11674                 ret_ref |= 1;
11675         }
11676         return ret_ref;
11677 }
11678
11679 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_ptr) {
11680         LDKGossipTimestampFilter this_ptr_conv;
11681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11682         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11683         GossipTimestampFilter_free(this_ptr_conv);
11684 }
11685
11686 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
11687         LDKGossipTimestampFilter orig_conv;
11688         orig_conv.inner = (void*)(orig & (~1));
11689         orig_conv.is_owned = false;
11690         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
11691         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11692         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11693         long ret_ref = (long)ret_var.inner;
11694         if (ret_var.is_owned) {
11695                 ret_ref |= 1;
11696         }
11697         return ret_ref;
11698 }
11699
11700 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
11701         LDKGossipTimestampFilter this_ptr_conv;
11702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11703         this_ptr_conv.is_owned = false;
11704         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11705         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
11706         return ret_arr;
11707 }
11708
11709 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11710         LDKGossipTimestampFilter this_ptr_conv;
11711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11712         this_ptr_conv.is_owned = false;
11713         LDKThirtyTwoBytes val_ref;
11714         CHECK(*((uint32_t*)val) == 32);
11715         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11716         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
11717 }
11718
11719 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
11720         LDKGossipTimestampFilter this_ptr_conv;
11721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11722         this_ptr_conv.is_owned = false;
11723         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
11724         return ret_val;
11725 }
11726
11727 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
11728         LDKGossipTimestampFilter this_ptr_conv;
11729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11730         this_ptr_conv.is_owned = false;
11731         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
11732 }
11733
11734 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
11735         LDKGossipTimestampFilter this_ptr_conv;
11736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11737         this_ptr_conv.is_owned = false;
11738         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
11739         return ret_val;
11740 }
11741
11742 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
11743         LDKGossipTimestampFilter this_ptr_conv;
11744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11745         this_ptr_conv.is_owned = false;
11746         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
11747 }
11748
11749 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
11750         LDKThirtyTwoBytes chain_hash_arg_ref;
11751         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11752         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11753         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
11754         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11755         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11756         long ret_ref = (long)ret_var.inner;
11757         if (ret_var.is_owned) {
11758                 ret_ref |= 1;
11759         }
11760         return ret_ref;
11761 }
11762
11763 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
11764         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
11765         FREE((void*)this_ptr);
11766         ErrorAction_free(this_ptr_conv);
11767 }
11768
11769 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
11770         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
11771         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11772         *ret_copy = ErrorAction_clone(orig_conv);
11773         long ret_ref = (long)ret_copy;
11774         return ret_ref;
11775 }
11776
11777 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_ptr) {
11778         LDKLightningError this_ptr_conv;
11779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11780         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11781         LightningError_free(this_ptr_conv);
11782 }
11783
11784 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
11785         LDKLightningError this_ptr_conv;
11786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11787         this_ptr_conv.is_owned = false;
11788         LDKStr _str = LightningError_get_err(&this_ptr_conv);
11789         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11790         return _conv;
11791 }
11792
11793 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
11794         LDKLightningError this_ptr_conv;
11795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11796         this_ptr_conv.is_owned = false;
11797         LDKCVec_u8Z val_ref;
11798         val_ref.datalen = *((uint32_t*)val);
11799         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11800         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11801         LightningError_set_err(&this_ptr_conv, val_ref);
11802 }
11803
11804 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
11805         LDKLightningError this_ptr_conv;
11806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11807         this_ptr_conv.is_owned = false;
11808         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11809         *ret_copy = LightningError_get_action(&this_ptr_conv);
11810         long ret_ref = (long)ret_copy;
11811         return ret_ref;
11812 }
11813
11814 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
11815         LDKLightningError this_ptr_conv;
11816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11817         this_ptr_conv.is_owned = false;
11818         LDKErrorAction val_conv = *(LDKErrorAction*)val;
11819         FREE((void*)val);
11820         LightningError_set_action(&this_ptr_conv, val_conv);
11821 }
11822
11823 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
11824         LDKCVec_u8Z err_arg_ref;
11825         err_arg_ref.datalen = *((uint32_t*)err_arg);
11826         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11827         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
11828         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
11829         FREE((void*)action_arg);
11830         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
11831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11833         long ret_ref = (long)ret_var.inner;
11834         if (ret_var.is_owned) {
11835                 ret_ref |= 1;
11836         }
11837         return ret_ref;
11838 }
11839
11840 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_ptr) {
11841         LDKCommitmentUpdate this_ptr_conv;
11842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11843         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11844         CommitmentUpdate_free(this_ptr_conv);
11845 }
11846
11847 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
11848         LDKCommitmentUpdate orig_conv;
11849         orig_conv.inner = (void*)(orig & (~1));
11850         orig_conv.is_owned = false;
11851         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
11852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11854         long ret_ref = (long)ret_var.inner;
11855         if (ret_var.is_owned) {
11856                 ret_ref |= 1;
11857         }
11858         return ret_ref;
11859 }
11860
11861 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
11862         LDKCommitmentUpdate this_ptr_conv;
11863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11864         this_ptr_conv.is_owned = false;
11865         LDKCVec_UpdateAddHTLCZ val_constr;
11866         val_constr.datalen = *((uint32_t*)val);
11867         if (val_constr.datalen > 0)
11868                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11869         else
11870                 val_constr.data = NULL;
11871         uint32_t* val_vals = (uint32_t*)(val + 4);
11872         for (size_t p = 0; p < val_constr.datalen; p++) {
11873                 uint32_t arr_conv_15 = val_vals[p];
11874                 LDKUpdateAddHTLC arr_conv_15_conv;
11875                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11876                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11877                 if (arr_conv_15_conv.inner != NULL)
11878                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11879                 val_constr.data[p] = arr_conv_15_conv;
11880         }
11881         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
11882 }
11883
11884 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
11885         LDKCommitmentUpdate this_ptr_conv;
11886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11887         this_ptr_conv.is_owned = false;
11888         LDKCVec_UpdateFulfillHTLCZ val_constr;
11889         val_constr.datalen = *((uint32_t*)val);
11890         if (val_constr.datalen > 0)
11891                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11892         else
11893                 val_constr.data = NULL;
11894         uint32_t* val_vals = (uint32_t*)(val + 4);
11895         for (size_t t = 0; t < val_constr.datalen; t++) {
11896                 uint32_t arr_conv_19 = val_vals[t];
11897                 LDKUpdateFulfillHTLC arr_conv_19_conv;
11898                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11899                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11900                 if (arr_conv_19_conv.inner != NULL)
11901                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11902                 val_constr.data[t] = arr_conv_19_conv;
11903         }
11904         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
11905 }
11906
11907 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
11908         LDKCommitmentUpdate this_ptr_conv;
11909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11910         this_ptr_conv.is_owned = false;
11911         LDKCVec_UpdateFailHTLCZ val_constr;
11912         val_constr.datalen = *((uint32_t*)val);
11913         if (val_constr.datalen > 0)
11914                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11915         else
11916                 val_constr.data = NULL;
11917         uint32_t* val_vals = (uint32_t*)(val + 4);
11918         for (size_t q = 0; q < val_constr.datalen; q++) {
11919                 uint32_t arr_conv_16 = val_vals[q];
11920                 LDKUpdateFailHTLC arr_conv_16_conv;
11921                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11922                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11923                 if (arr_conv_16_conv.inner != NULL)
11924                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11925                 val_constr.data[q] = arr_conv_16_conv;
11926         }
11927         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
11928 }
11929
11930 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
11931         LDKCommitmentUpdate this_ptr_conv;
11932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11933         this_ptr_conv.is_owned = false;
11934         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
11935         val_constr.datalen = *((uint32_t*)val);
11936         if (val_constr.datalen > 0)
11937                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11938         else
11939                 val_constr.data = NULL;
11940         uint32_t* val_vals = (uint32_t*)(val + 4);
11941         for (size_t z = 0; z < val_constr.datalen; z++) {
11942                 uint32_t arr_conv_25 = val_vals[z];
11943                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11944                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11945                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11946                 if (arr_conv_25_conv.inner != NULL)
11947                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11948                 val_constr.data[z] = arr_conv_25_conv;
11949         }
11950         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
11951 }
11952
11953 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
11954         LDKCommitmentUpdate this_ptr_conv;
11955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11956         this_ptr_conv.is_owned = false;
11957         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
11958         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11959         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11960         long ret_ref = (long)ret_var.inner;
11961         if (ret_var.is_owned) {
11962                 ret_ref |= 1;
11963         }
11964         return ret_ref;
11965 }
11966
11967 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
11968         LDKCommitmentUpdate this_ptr_conv;
11969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11970         this_ptr_conv.is_owned = false;
11971         LDKUpdateFee val_conv;
11972         val_conv.inner = (void*)(val & (~1));
11973         val_conv.is_owned = (val & 1) || (val == 0);
11974         if (val_conv.inner != NULL)
11975                 val_conv = UpdateFee_clone(&val_conv);
11976         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
11977 }
11978
11979 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
11980         LDKCommitmentUpdate this_ptr_conv;
11981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11982         this_ptr_conv.is_owned = false;
11983         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
11984         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11985         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11986         long ret_ref = (long)ret_var.inner;
11987         if (ret_var.is_owned) {
11988                 ret_ref |= 1;
11989         }
11990         return ret_ref;
11991 }
11992
11993 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
11994         LDKCommitmentUpdate this_ptr_conv;
11995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11996         this_ptr_conv.is_owned = false;
11997         LDKCommitmentSigned val_conv;
11998         val_conv.inner = (void*)(val & (~1));
11999         val_conv.is_owned = (val & 1) || (val == 0);
12000         if (val_conv.inner != NULL)
12001                 val_conv = CommitmentSigned_clone(&val_conv);
12002         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
12003 }
12004
12005 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) {
12006         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
12007         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
12008         if (update_add_htlcs_arg_constr.datalen > 0)
12009                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12010         else
12011                 update_add_htlcs_arg_constr.data = NULL;
12012         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
12013         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
12014                 uint32_t arr_conv_15 = update_add_htlcs_arg_vals[p];
12015                 LDKUpdateAddHTLC arr_conv_15_conv;
12016                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
12017                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
12018                 if (arr_conv_15_conv.inner != NULL)
12019                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
12020                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
12021         }
12022         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
12023         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
12024         if (update_fulfill_htlcs_arg_constr.datalen > 0)
12025                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12026         else
12027                 update_fulfill_htlcs_arg_constr.data = NULL;
12028         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
12029         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
12030                 uint32_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
12031                 LDKUpdateFulfillHTLC arr_conv_19_conv;
12032                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
12033                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
12034                 if (arr_conv_19_conv.inner != NULL)
12035                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
12036                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
12037         }
12038         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
12039         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
12040         if (update_fail_htlcs_arg_constr.datalen > 0)
12041                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12042         else
12043                 update_fail_htlcs_arg_constr.data = NULL;
12044         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
12045         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
12046                 uint32_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
12047                 LDKUpdateFailHTLC arr_conv_16_conv;
12048                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
12049                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
12050                 if (arr_conv_16_conv.inner != NULL)
12051                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
12052                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
12053         }
12054         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
12055         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
12056         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
12057                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12058         else
12059                 update_fail_malformed_htlcs_arg_constr.data = NULL;
12060         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
12061         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
12062                 uint32_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
12063                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
12064                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
12065                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
12066                 if (arr_conv_25_conv.inner != NULL)
12067                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
12068                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
12069         }
12070         LDKUpdateFee update_fee_arg_conv;
12071         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
12072         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
12073         if (update_fee_arg_conv.inner != NULL)
12074                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
12075         LDKCommitmentSigned commitment_signed_arg_conv;
12076         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
12077         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
12078         if (commitment_signed_arg_conv.inner != NULL)
12079                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
12080         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);
12081         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12082         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12083         long ret_ref = (long)ret_var.inner;
12084         if (ret_var.is_owned) {
12085                 ret_ref |= 1;
12086         }
12087         return ret_ref;
12088 }
12089
12090 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
12091         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
12092         FREE((void*)this_ptr);
12093         HTLCFailChannelUpdate_free(this_ptr_conv);
12094 }
12095
12096 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
12097         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
12098         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
12099         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
12100         long ret_ref = (long)ret_copy;
12101         return ret_ref;
12102 }
12103
12104 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
12105         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
12106         FREE((void*)this_ptr);
12107         ChannelMessageHandler_free(this_ptr_conv);
12108 }
12109
12110 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
12111         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
12112         FREE((void*)this_ptr);
12113         RoutingMessageHandler_free(this_ptr_conv);
12114 }
12115
12116 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
12117         LDKAcceptChannel obj_conv;
12118         obj_conv.inner = (void*)(obj & (~1));
12119         obj_conv.is_owned = false;
12120         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
12121         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12122         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12123         CVec_u8Z_free(arg_var);
12124         return arg_arr;
12125 }
12126
12127 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
12128         LDKu8slice ser_ref;
12129         ser_ref.datalen = *((uint32_t*)ser);
12130         ser_ref.data = (int8_t*)(ser + 4);
12131         LDKAcceptChannel ret_var = AcceptChannel_read(ser_ref);
12132         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12133         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12134         long ret_ref = (long)ret_var.inner;
12135         if (ret_var.is_owned) {
12136                 ret_ref |= 1;
12137         }
12138         return ret_ref;
12139 }
12140
12141 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
12142         LDKAnnouncementSignatures obj_conv;
12143         obj_conv.inner = (void*)(obj & (~1));
12144         obj_conv.is_owned = false;
12145         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
12146         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12147         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12148         CVec_u8Z_free(arg_var);
12149         return arg_arr;
12150 }
12151
12152 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
12153         LDKu8slice ser_ref;
12154         ser_ref.datalen = *((uint32_t*)ser);
12155         ser_ref.data = (int8_t*)(ser + 4);
12156         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_read(ser_ref);
12157         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12158         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12159         long ret_ref = (long)ret_var.inner;
12160         if (ret_var.is_owned) {
12161                 ret_ref |= 1;
12162         }
12163         return ret_ref;
12164 }
12165
12166 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
12167         LDKChannelReestablish obj_conv;
12168         obj_conv.inner = (void*)(obj & (~1));
12169         obj_conv.is_owned = false;
12170         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
12171         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12172         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12173         CVec_u8Z_free(arg_var);
12174         return arg_arr;
12175 }
12176
12177 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
12178         LDKu8slice ser_ref;
12179         ser_ref.datalen = *((uint32_t*)ser);
12180         ser_ref.data = (int8_t*)(ser + 4);
12181         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12182         *ret_conv = ChannelReestablish_read(ser_ref);
12183         return (long)ret_conv;
12184 }
12185
12186 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
12187         LDKClosingSigned obj_conv;
12188         obj_conv.inner = (void*)(obj & (~1));
12189         obj_conv.is_owned = false;
12190         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
12191         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12192         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12193         CVec_u8Z_free(arg_var);
12194         return arg_arr;
12195 }
12196
12197 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
12198         LDKu8slice ser_ref;
12199         ser_ref.datalen = *((uint32_t*)ser);
12200         ser_ref.data = (int8_t*)(ser + 4);
12201         LDKClosingSigned ret_var = ClosingSigned_read(ser_ref);
12202         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12203         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12204         long ret_ref = (long)ret_var.inner;
12205         if (ret_var.is_owned) {
12206                 ret_ref |= 1;
12207         }
12208         return ret_ref;
12209 }
12210
12211 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
12212         LDKCommitmentSigned obj_conv;
12213         obj_conv.inner = (void*)(obj & (~1));
12214         obj_conv.is_owned = false;
12215         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
12216         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12217         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12218         CVec_u8Z_free(arg_var);
12219         return arg_arr;
12220 }
12221
12222 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
12223         LDKu8slice ser_ref;
12224         ser_ref.datalen = *((uint32_t*)ser);
12225         ser_ref.data = (int8_t*)(ser + 4);
12226         LDKCommitmentSigned ret_var = CommitmentSigned_read(ser_ref);
12227         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12228         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12229         long ret_ref = (long)ret_var.inner;
12230         if (ret_var.is_owned) {
12231                 ret_ref |= 1;
12232         }
12233         return ret_ref;
12234 }
12235
12236 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
12237         LDKFundingCreated obj_conv;
12238         obj_conv.inner = (void*)(obj & (~1));
12239         obj_conv.is_owned = false;
12240         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
12241         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12242         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12243         CVec_u8Z_free(arg_var);
12244         return arg_arr;
12245 }
12246
12247 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
12248         LDKu8slice ser_ref;
12249         ser_ref.datalen = *((uint32_t*)ser);
12250         ser_ref.data = (int8_t*)(ser + 4);
12251         LDKFundingCreated ret_var = FundingCreated_read(ser_ref);
12252         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12253         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12254         long ret_ref = (long)ret_var.inner;
12255         if (ret_var.is_owned) {
12256                 ret_ref |= 1;
12257         }
12258         return ret_ref;
12259 }
12260
12261 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
12262         LDKFundingSigned obj_conv;
12263         obj_conv.inner = (void*)(obj & (~1));
12264         obj_conv.is_owned = false;
12265         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
12266         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12267         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12268         CVec_u8Z_free(arg_var);
12269         return arg_arr;
12270 }
12271
12272 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
12273         LDKu8slice ser_ref;
12274         ser_ref.datalen = *((uint32_t*)ser);
12275         ser_ref.data = (int8_t*)(ser + 4);
12276         LDKFundingSigned ret_var = FundingSigned_read(ser_ref);
12277         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12278         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12279         long ret_ref = (long)ret_var.inner;
12280         if (ret_var.is_owned) {
12281                 ret_ref |= 1;
12282         }
12283         return ret_ref;
12284 }
12285
12286 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
12287         LDKFundingLocked obj_conv;
12288         obj_conv.inner = (void*)(obj & (~1));
12289         obj_conv.is_owned = false;
12290         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
12291         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12292         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12293         CVec_u8Z_free(arg_var);
12294         return arg_arr;
12295 }
12296
12297 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
12298         LDKu8slice ser_ref;
12299         ser_ref.datalen = *((uint32_t*)ser);
12300         ser_ref.data = (int8_t*)(ser + 4);
12301         LDKFundingLocked ret_var = FundingLocked_read(ser_ref);
12302         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12303         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12304         long ret_ref = (long)ret_var.inner;
12305         if (ret_var.is_owned) {
12306                 ret_ref |= 1;
12307         }
12308         return ret_ref;
12309 }
12310
12311 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
12312         LDKInit obj_conv;
12313         obj_conv.inner = (void*)(obj & (~1));
12314         obj_conv.is_owned = false;
12315         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
12316         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12317         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12318         CVec_u8Z_free(arg_var);
12319         return arg_arr;
12320 }
12321
12322 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
12323         LDKu8slice ser_ref;
12324         ser_ref.datalen = *((uint32_t*)ser);
12325         ser_ref.data = (int8_t*)(ser + 4);
12326         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12327         *ret_conv = Init_read(ser_ref);
12328         return (long)ret_conv;
12329 }
12330
12331 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
12332         LDKOpenChannel obj_conv;
12333         obj_conv.inner = (void*)(obj & (~1));
12334         obj_conv.is_owned = false;
12335         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
12336         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12337         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12338         CVec_u8Z_free(arg_var);
12339         return arg_arr;
12340 }
12341
12342 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
12343         LDKu8slice ser_ref;
12344         ser_ref.datalen = *((uint32_t*)ser);
12345         ser_ref.data = (int8_t*)(ser + 4);
12346         LDKOpenChannel ret_var = OpenChannel_read(ser_ref);
12347         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12348         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12349         long ret_ref = (long)ret_var.inner;
12350         if (ret_var.is_owned) {
12351                 ret_ref |= 1;
12352         }
12353         return ret_ref;
12354 }
12355
12356 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
12357         LDKRevokeAndACK obj_conv;
12358         obj_conv.inner = (void*)(obj & (~1));
12359         obj_conv.is_owned = false;
12360         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
12361         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12362         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12363         CVec_u8Z_free(arg_var);
12364         return arg_arr;
12365 }
12366
12367 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
12368         LDKu8slice ser_ref;
12369         ser_ref.datalen = *((uint32_t*)ser);
12370         ser_ref.data = (int8_t*)(ser + 4);
12371         LDKRevokeAndACK ret_var = RevokeAndACK_read(ser_ref);
12372         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12373         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12374         long ret_ref = (long)ret_var.inner;
12375         if (ret_var.is_owned) {
12376                 ret_ref |= 1;
12377         }
12378         return ret_ref;
12379 }
12380
12381 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
12382         LDKShutdown obj_conv;
12383         obj_conv.inner = (void*)(obj & (~1));
12384         obj_conv.is_owned = false;
12385         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
12386         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12387         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12388         CVec_u8Z_free(arg_var);
12389         return arg_arr;
12390 }
12391
12392 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
12393         LDKu8slice ser_ref;
12394         ser_ref.datalen = *((uint32_t*)ser);
12395         ser_ref.data = (int8_t*)(ser + 4);
12396         LDKShutdown ret_var = Shutdown_read(ser_ref);
12397         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12398         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12399         long ret_ref = (long)ret_var.inner;
12400         if (ret_var.is_owned) {
12401                 ret_ref |= 1;
12402         }
12403         return ret_ref;
12404 }
12405
12406 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
12407         LDKUpdateFailHTLC obj_conv;
12408         obj_conv.inner = (void*)(obj & (~1));
12409         obj_conv.is_owned = false;
12410         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
12411         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12412         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12413         CVec_u8Z_free(arg_var);
12414         return arg_arr;
12415 }
12416
12417 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
12418         LDKu8slice ser_ref;
12419         ser_ref.datalen = *((uint32_t*)ser);
12420         ser_ref.data = (int8_t*)(ser + 4);
12421         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_read(ser_ref);
12422         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12423         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12424         long ret_ref = (long)ret_var.inner;
12425         if (ret_var.is_owned) {
12426                 ret_ref |= 1;
12427         }
12428         return ret_ref;
12429 }
12430
12431 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
12432         LDKUpdateFailMalformedHTLC obj_conv;
12433         obj_conv.inner = (void*)(obj & (~1));
12434         obj_conv.is_owned = false;
12435         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
12436         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12437         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12438         CVec_u8Z_free(arg_var);
12439         return arg_arr;
12440 }
12441
12442 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
12443         LDKu8slice ser_ref;
12444         ser_ref.datalen = *((uint32_t*)ser);
12445         ser_ref.data = (int8_t*)(ser + 4);
12446         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_read(ser_ref);
12447         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12448         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12449         long ret_ref = (long)ret_var.inner;
12450         if (ret_var.is_owned) {
12451                 ret_ref |= 1;
12452         }
12453         return ret_ref;
12454 }
12455
12456 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
12457         LDKUpdateFee obj_conv;
12458         obj_conv.inner = (void*)(obj & (~1));
12459         obj_conv.is_owned = false;
12460         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
12461         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12462         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12463         CVec_u8Z_free(arg_var);
12464         return arg_arr;
12465 }
12466
12467 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
12468         LDKu8slice ser_ref;
12469         ser_ref.datalen = *((uint32_t*)ser);
12470         ser_ref.data = (int8_t*)(ser + 4);
12471         LDKUpdateFee ret_var = UpdateFee_read(ser_ref);
12472         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12473         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12474         long ret_ref = (long)ret_var.inner;
12475         if (ret_var.is_owned) {
12476                 ret_ref |= 1;
12477         }
12478         return ret_ref;
12479 }
12480
12481 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
12482         LDKUpdateFulfillHTLC obj_conv;
12483         obj_conv.inner = (void*)(obj & (~1));
12484         obj_conv.is_owned = false;
12485         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
12486         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12487         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12488         CVec_u8Z_free(arg_var);
12489         return arg_arr;
12490 }
12491
12492 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
12493         LDKu8slice ser_ref;
12494         ser_ref.datalen = *((uint32_t*)ser);
12495         ser_ref.data = (int8_t*)(ser + 4);
12496         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_read(ser_ref);
12497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12499         long ret_ref = (long)ret_var.inner;
12500         if (ret_var.is_owned) {
12501                 ret_ref |= 1;
12502         }
12503         return ret_ref;
12504 }
12505
12506 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
12507         LDKUpdateAddHTLC obj_conv;
12508         obj_conv.inner = (void*)(obj & (~1));
12509         obj_conv.is_owned = false;
12510         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
12511         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12512         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12513         CVec_u8Z_free(arg_var);
12514         return arg_arr;
12515 }
12516
12517 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
12518         LDKu8slice ser_ref;
12519         ser_ref.datalen = *((uint32_t*)ser);
12520         ser_ref.data = (int8_t*)(ser + 4);
12521         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_read(ser_ref);
12522         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12523         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12524         long ret_ref = (long)ret_var.inner;
12525         if (ret_var.is_owned) {
12526                 ret_ref |= 1;
12527         }
12528         return ret_ref;
12529 }
12530
12531 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
12532         LDKPing obj_conv;
12533         obj_conv.inner = (void*)(obj & (~1));
12534         obj_conv.is_owned = false;
12535         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
12536         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12537         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12538         CVec_u8Z_free(arg_var);
12539         return arg_arr;
12540 }
12541
12542 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
12543         LDKu8slice ser_ref;
12544         ser_ref.datalen = *((uint32_t*)ser);
12545         ser_ref.data = (int8_t*)(ser + 4);
12546         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12547         *ret_conv = Ping_read(ser_ref);
12548         return (long)ret_conv;
12549 }
12550
12551 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
12552         LDKPong obj_conv;
12553         obj_conv.inner = (void*)(obj & (~1));
12554         obj_conv.is_owned = false;
12555         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
12556         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12557         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12558         CVec_u8Z_free(arg_var);
12559         return arg_arr;
12560 }
12561
12562 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
12563         LDKu8slice ser_ref;
12564         ser_ref.datalen = *((uint32_t*)ser);
12565         ser_ref.data = (int8_t*)(ser + 4);
12566         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12567         *ret_conv = Pong_read(ser_ref);
12568         return (long)ret_conv;
12569 }
12570
12571 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
12572         LDKUnsignedChannelAnnouncement obj_conv;
12573         obj_conv.inner = (void*)(obj & (~1));
12574         obj_conv.is_owned = false;
12575         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
12576         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12577         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12578         CVec_u8Z_free(arg_var);
12579         return arg_arr;
12580 }
12581
12582 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
12583         LDKu8slice ser_ref;
12584         ser_ref.datalen = *((uint32_t*)ser);
12585         ser_ref.data = (int8_t*)(ser + 4);
12586         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12587         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
12588         return (long)ret_conv;
12589 }
12590
12591 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
12592         LDKChannelAnnouncement obj_conv;
12593         obj_conv.inner = (void*)(obj & (~1));
12594         obj_conv.is_owned = false;
12595         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
12596         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12597         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12598         CVec_u8Z_free(arg_var);
12599         return arg_arr;
12600 }
12601
12602 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
12603         LDKu8slice ser_ref;
12604         ser_ref.datalen = *((uint32_t*)ser);
12605         ser_ref.data = (int8_t*)(ser + 4);
12606         LDKChannelAnnouncement ret_var = ChannelAnnouncement_read(ser_ref);
12607         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12608         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12609         long ret_ref = (long)ret_var.inner;
12610         if (ret_var.is_owned) {
12611                 ret_ref |= 1;
12612         }
12613         return ret_ref;
12614 }
12615
12616 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
12617         LDKUnsignedChannelUpdate obj_conv;
12618         obj_conv.inner = (void*)(obj & (~1));
12619         obj_conv.is_owned = false;
12620         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
12621         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12622         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12623         CVec_u8Z_free(arg_var);
12624         return arg_arr;
12625 }
12626
12627 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
12628         LDKu8slice ser_ref;
12629         ser_ref.datalen = *((uint32_t*)ser);
12630         ser_ref.data = (int8_t*)(ser + 4);
12631         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12632         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
12633         return (long)ret_conv;
12634 }
12635
12636 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
12637         LDKChannelUpdate obj_conv;
12638         obj_conv.inner = (void*)(obj & (~1));
12639         obj_conv.is_owned = false;
12640         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
12641         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12642         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12643         CVec_u8Z_free(arg_var);
12644         return arg_arr;
12645 }
12646
12647 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
12648         LDKu8slice ser_ref;
12649         ser_ref.datalen = *((uint32_t*)ser);
12650         ser_ref.data = (int8_t*)(ser + 4);
12651         LDKChannelUpdate ret_var = ChannelUpdate_read(ser_ref);
12652         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12653         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12654         long ret_ref = (long)ret_var.inner;
12655         if (ret_var.is_owned) {
12656                 ret_ref |= 1;
12657         }
12658         return ret_ref;
12659 }
12660
12661 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
12662         LDKErrorMessage obj_conv;
12663         obj_conv.inner = (void*)(obj & (~1));
12664         obj_conv.is_owned = false;
12665         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
12666         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12667         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12668         CVec_u8Z_free(arg_var);
12669         return arg_arr;
12670 }
12671
12672 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
12673         LDKu8slice ser_ref;
12674         ser_ref.datalen = *((uint32_t*)ser);
12675         ser_ref.data = (int8_t*)(ser + 4);
12676         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12677         *ret_conv = ErrorMessage_read(ser_ref);
12678         return (long)ret_conv;
12679 }
12680
12681 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
12682         LDKUnsignedNodeAnnouncement obj_conv;
12683         obj_conv.inner = (void*)(obj & (~1));
12684         obj_conv.is_owned = false;
12685         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
12686         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12687         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12688         CVec_u8Z_free(arg_var);
12689         return arg_arr;
12690 }
12691
12692 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
12693         LDKu8slice ser_ref;
12694         ser_ref.datalen = *((uint32_t*)ser);
12695         ser_ref.data = (int8_t*)(ser + 4);
12696         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12697         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
12698         return (long)ret_conv;
12699 }
12700
12701 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
12702         LDKNodeAnnouncement obj_conv;
12703         obj_conv.inner = (void*)(obj & (~1));
12704         obj_conv.is_owned = false;
12705         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
12706         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12707         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12708         CVec_u8Z_free(arg_var);
12709         return arg_arr;
12710 }
12711
12712 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
12713         LDKu8slice ser_ref;
12714         ser_ref.datalen = *((uint32_t*)ser);
12715         ser_ref.data = (int8_t*)(ser + 4);
12716         LDKNodeAnnouncement ret_var = NodeAnnouncement_read(ser_ref);
12717         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12718         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12719         long ret_ref = (long)ret_var.inner;
12720         if (ret_var.is_owned) {
12721                 ret_ref |= 1;
12722         }
12723         return ret_ref;
12724 }
12725
12726 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
12727         LDKu8slice ser_ref;
12728         ser_ref.datalen = *((uint32_t*)ser);
12729         ser_ref.data = (int8_t*)(ser + 4);
12730         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12731         *ret_conv = QueryShortChannelIds_read(ser_ref);
12732         return (long)ret_conv;
12733 }
12734
12735 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
12736         LDKQueryShortChannelIds obj_conv;
12737         obj_conv.inner = (void*)(obj & (~1));
12738         obj_conv.is_owned = false;
12739         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
12740         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12741         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12742         CVec_u8Z_free(arg_var);
12743         return arg_arr;
12744 }
12745
12746 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
12747         LDKu8slice ser_ref;
12748         ser_ref.datalen = *((uint32_t*)ser);
12749         ser_ref.data = (int8_t*)(ser + 4);
12750         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12751         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
12752         return (long)ret_conv;
12753 }
12754
12755 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
12756         LDKReplyShortChannelIdsEnd obj_conv;
12757         obj_conv.inner = (void*)(obj & (~1));
12758         obj_conv.is_owned = false;
12759         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
12760         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12761         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12762         CVec_u8Z_free(arg_var);
12763         return arg_arr;
12764 }
12765
12766 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
12767         LDKu8slice ser_ref;
12768         ser_ref.datalen = *((uint32_t*)ser);
12769         ser_ref.data = (int8_t*)(ser + 4);
12770         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12771         *ret_conv = QueryChannelRange_read(ser_ref);
12772         return (long)ret_conv;
12773 }
12774
12775 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
12776         LDKQueryChannelRange obj_conv;
12777         obj_conv.inner = (void*)(obj & (~1));
12778         obj_conv.is_owned = false;
12779         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
12780         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12781         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12782         CVec_u8Z_free(arg_var);
12783         return arg_arr;
12784 }
12785
12786 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
12787         LDKu8slice ser_ref;
12788         ser_ref.datalen = *((uint32_t*)ser);
12789         ser_ref.data = (int8_t*)(ser + 4);
12790         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12791         *ret_conv = ReplyChannelRange_read(ser_ref);
12792         return (long)ret_conv;
12793 }
12794
12795 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
12796         LDKReplyChannelRange obj_conv;
12797         obj_conv.inner = (void*)(obj & (~1));
12798         obj_conv.is_owned = false;
12799         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
12800         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12801         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12802         CVec_u8Z_free(arg_var);
12803         return arg_arr;
12804 }
12805
12806 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
12807         LDKu8slice ser_ref;
12808         ser_ref.datalen = *((uint32_t*)ser);
12809         ser_ref.data = (int8_t*)(ser + 4);
12810         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12811         *ret_conv = GossipTimestampFilter_read(ser_ref);
12812         return (long)ret_conv;
12813 }
12814
12815 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
12816         LDKGossipTimestampFilter obj_conv;
12817         obj_conv.inner = (void*)(obj & (~1));
12818         obj_conv.is_owned = false;
12819         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
12820         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12821         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12822         CVec_u8Z_free(arg_var);
12823         return arg_arr;
12824 }
12825
12826 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_ptr) {
12827         LDKMessageHandler this_ptr_conv;
12828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12829         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12830         MessageHandler_free(this_ptr_conv);
12831 }
12832
12833 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
12834         LDKMessageHandler this_ptr_conv;
12835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12836         this_ptr_conv.is_owned = false;
12837         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
12838         return ret_ret;
12839 }
12840
12841 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
12842         LDKMessageHandler this_ptr_conv;
12843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12844         this_ptr_conv.is_owned = false;
12845         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
12846         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
12847 }
12848
12849 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
12850         LDKMessageHandler this_ptr_conv;
12851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12852         this_ptr_conv.is_owned = false;
12853         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
12854         return ret_ret;
12855 }
12856
12857 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
12858         LDKMessageHandler this_ptr_conv;
12859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12860         this_ptr_conv.is_owned = false;
12861         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
12862         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
12863 }
12864
12865 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
12866         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
12867         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
12868         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
12869         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12870         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12871         long ret_ref = (long)ret_var.inner;
12872         if (ret_var.is_owned) {
12873                 ret_ref |= 1;
12874         }
12875         return ret_ref;
12876 }
12877
12878 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
12879         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
12880         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12881         *ret = SocketDescriptor_clone(orig_conv);
12882         return (long)ret;
12883 }
12884
12885 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
12886         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
12887         FREE((void*)this_ptr);
12888         SocketDescriptor_free(this_ptr_conv);
12889 }
12890
12891 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_ptr) {
12892         LDKPeerHandleError this_ptr_conv;
12893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12894         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12895         PeerHandleError_free(this_ptr_conv);
12896 }
12897
12898 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
12899         LDKPeerHandleError this_ptr_conv;
12900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12901         this_ptr_conv.is_owned = false;
12902         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
12903         return ret_val;
12904 }
12905
12906 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
12907         LDKPeerHandleError this_ptr_conv;
12908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12909         this_ptr_conv.is_owned = false;
12910         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
12911 }
12912
12913 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
12914         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
12915         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12916         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12917         long ret_ref = (long)ret_var.inner;
12918         if (ret_var.is_owned) {
12919                 ret_ref |= 1;
12920         }
12921         return ret_ref;
12922 }
12923
12924 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_ptr) {
12925         LDKPeerManager this_ptr_conv;
12926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12927         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12928         PeerManager_free(this_ptr_conv);
12929 }
12930
12931 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) {
12932         LDKMessageHandler message_handler_conv;
12933         message_handler_conv.inner = (void*)(message_handler & (~1));
12934         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
12935         // Warning: we may need a move here but can't clone!
12936         LDKSecretKey our_node_secret_ref;
12937         CHECK(*((uint32_t*)our_node_secret) == 32);
12938         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
12939         unsigned char ephemeral_random_data_arr[32];
12940         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
12941         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
12942         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
12943         LDKLogger logger_conv = *(LDKLogger*)logger;
12944         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
12945         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12946         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12947         long ret_ref = (long)ret_var.inner;
12948         if (ret_var.is_owned) {
12949                 ret_ref |= 1;
12950         }
12951         return ret_ref;
12952 }
12953
12954 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
12955         LDKPeerManager this_arg_conv;
12956         this_arg_conv.inner = (void*)(this_arg & (~1));
12957         this_arg_conv.is_owned = false;
12958         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
12959         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12960         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12961         for (size_t m = 0; m < ret_var.datalen; m++) {
12962                 int8_tArray arr_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12963                 memcpy((uint8_t*)(arr_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
12964                 ret_arr_ptr[m] = arr_conv_12_arr;
12965         }
12966         FREE(ret_var.data);
12967         return ret_arr;
12968 }
12969
12970 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
12971         LDKPeerManager this_arg_conv;
12972         this_arg_conv.inner = (void*)(this_arg & (~1));
12973         this_arg_conv.is_owned = false;
12974         LDKPublicKey their_node_id_ref;
12975         CHECK(*((uint32_t*)their_node_id) == 33);
12976         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
12977         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12978         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12979         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
12980         return (long)ret_conv;
12981 }
12982
12983 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
12984         LDKPeerManager this_arg_conv;
12985         this_arg_conv.inner = (void*)(this_arg & (~1));
12986         this_arg_conv.is_owned = false;
12987         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12988         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12989         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
12990         return (long)ret_conv;
12991 }
12992
12993 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
12994         LDKPeerManager this_arg_conv;
12995         this_arg_conv.inner = (void*)(this_arg & (~1));
12996         this_arg_conv.is_owned = false;
12997         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12998         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12999         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
13000         return (long)ret_conv;
13001 }
13002
13003 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
13004         LDKPeerManager this_arg_conv;
13005         this_arg_conv.inner = (void*)(this_arg & (~1));
13006         this_arg_conv.is_owned = false;
13007         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
13008         LDKu8slice data_ref;
13009         data_ref.datalen = *((uint32_t*)data);
13010         data_ref.data = (int8_t*)(data + 4);
13011         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13012         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
13013         return (long)ret_conv;
13014 }
13015
13016 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
13017         LDKPeerManager this_arg_conv;
13018         this_arg_conv.inner = (void*)(this_arg & (~1));
13019         this_arg_conv.is_owned = false;
13020         PeerManager_process_events(&this_arg_conv);
13021 }
13022
13023 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
13024         LDKPeerManager this_arg_conv;
13025         this_arg_conv.inner = (void*)(this_arg & (~1));
13026         this_arg_conv.is_owned = false;
13027         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
13028         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
13029 }
13030
13031 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occured(uint32_t this_arg) {
13032         LDKPeerManager this_arg_conv;
13033         this_arg_conv.inner = (void*)(this_arg & (~1));
13034         this_arg_conv.is_owned = false;
13035         PeerManager_timer_tick_occured(&this_arg_conv);
13036 }
13037
13038 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
13039         unsigned char commitment_seed_arr[32];
13040         CHECK(*((uint32_t*)commitment_seed) == 32);
13041         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
13042         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
13043         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13044         memcpy((uint8_t*)(arg_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
13045         return arg_arr;
13046 }
13047
13048 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
13049         LDKPublicKey per_commitment_point_ref;
13050         CHECK(*((uint32_t*)per_commitment_point) == 33);
13051         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13052         unsigned char base_secret_arr[32];
13053         CHECK(*((uint32_t*)base_secret) == 32);
13054         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
13055         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
13056         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
13057         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
13058         return (long)ret_conv;
13059 }
13060
13061 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
13062         LDKPublicKey per_commitment_point_ref;
13063         CHECK(*((uint32_t*)per_commitment_point) == 33);
13064         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13065         LDKPublicKey base_point_ref;
13066         CHECK(*((uint32_t*)base_point) == 33);
13067         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
13068         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
13069         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
13070         return (long)ret_conv;
13071 }
13072
13073 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
13074         unsigned char per_commitment_secret_arr[32];
13075         CHECK(*((uint32_t*)per_commitment_secret) == 32);
13076         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
13077         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
13078         unsigned char countersignatory_revocation_base_secret_arr[32];
13079         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
13080         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
13081         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
13082         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
13083         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
13084         return (long)ret_conv;
13085 }
13086
13087 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
13088         LDKPublicKey per_commitment_point_ref;
13089         CHECK(*((uint32_t*)per_commitment_point) == 33);
13090         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13091         LDKPublicKey countersignatory_revocation_base_point_ref;
13092         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
13093         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
13094         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
13095         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
13096         return (long)ret_conv;
13097 }
13098
13099 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_ptr) {
13100         LDKTxCreationKeys this_ptr_conv;
13101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13102         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13103         TxCreationKeys_free(this_ptr_conv);
13104 }
13105
13106 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
13107         LDKTxCreationKeys orig_conv;
13108         orig_conv.inner = (void*)(orig & (~1));
13109         orig_conv.is_owned = false;
13110         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
13111         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13112         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13113         long ret_ref = (long)ret_var.inner;
13114         if (ret_var.is_owned) {
13115                 ret_ref |= 1;
13116         }
13117         return ret_ref;
13118 }
13119
13120 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
13121         LDKTxCreationKeys this_ptr_conv;
13122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13123         this_ptr_conv.is_owned = false;
13124         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13125         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13126         return arg_arr;
13127 }
13128
13129 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13130         LDKTxCreationKeys this_ptr_conv;
13131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13132         this_ptr_conv.is_owned = false;
13133         LDKPublicKey val_ref;
13134         CHECK(*((uint32_t*)val) == 33);
13135         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13136         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
13137 }
13138
13139 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
13140         LDKTxCreationKeys this_ptr_conv;
13141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13142         this_ptr_conv.is_owned = false;
13143         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13144         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
13145         return arg_arr;
13146 }
13147
13148 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
13149         LDKTxCreationKeys this_ptr_conv;
13150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13151         this_ptr_conv.is_owned = false;
13152         LDKPublicKey val_ref;
13153         CHECK(*((uint32_t*)val) == 33);
13154         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13155         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
13156 }
13157
13158 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
13159         LDKTxCreationKeys this_ptr_conv;
13160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13161         this_ptr_conv.is_owned = false;
13162         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13163         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
13164         return arg_arr;
13165 }
13166
13167 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
13168         LDKTxCreationKeys this_ptr_conv;
13169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13170         this_ptr_conv.is_owned = false;
13171         LDKPublicKey val_ref;
13172         CHECK(*((uint32_t*)val) == 33);
13173         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13174         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
13175 }
13176
13177 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
13178         LDKTxCreationKeys this_ptr_conv;
13179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13180         this_ptr_conv.is_owned = false;
13181         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13182         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
13183         return arg_arr;
13184 }
13185
13186 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
13187         LDKTxCreationKeys this_ptr_conv;
13188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13189         this_ptr_conv.is_owned = false;
13190         LDKPublicKey val_ref;
13191         CHECK(*((uint32_t*)val) == 33);
13192         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13193         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
13194 }
13195
13196 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
13197         LDKTxCreationKeys this_ptr_conv;
13198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13199         this_ptr_conv.is_owned = false;
13200         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13201         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
13202         return arg_arr;
13203 }
13204
13205 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
13206         LDKTxCreationKeys this_ptr_conv;
13207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13208         this_ptr_conv.is_owned = false;
13209         LDKPublicKey val_ref;
13210         CHECK(*((uint32_t*)val) == 33);
13211         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13212         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
13213 }
13214
13215 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) {
13216         LDKPublicKey per_commitment_point_arg_ref;
13217         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
13218         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
13219         LDKPublicKey revocation_key_arg_ref;
13220         CHECK(*((uint32_t*)revocation_key_arg) == 33);
13221         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
13222         LDKPublicKey broadcaster_htlc_key_arg_ref;
13223         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
13224         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
13225         LDKPublicKey countersignatory_htlc_key_arg_ref;
13226         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
13227         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
13228         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
13229         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
13230         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
13231         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);
13232         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13233         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13234         long ret_ref = (long)ret_var.inner;
13235         if (ret_var.is_owned) {
13236                 ret_ref |= 1;
13237         }
13238         return ret_ref;
13239 }
13240
13241 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
13242         LDKTxCreationKeys obj_conv;
13243         obj_conv.inner = (void*)(obj & (~1));
13244         obj_conv.is_owned = false;
13245         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
13246         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13247         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13248         CVec_u8Z_free(arg_var);
13249         return arg_arr;
13250 }
13251
13252 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
13253         LDKu8slice ser_ref;
13254         ser_ref.datalen = *((uint32_t*)ser);
13255         ser_ref.data = (int8_t*)(ser + 4);
13256         LDKTxCreationKeys ret_var = TxCreationKeys_read(ser_ref);
13257         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13258         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13259         long ret_ref = (long)ret_var.inner;
13260         if (ret_var.is_owned) {
13261                 ret_ref |= 1;
13262         }
13263         return ret_ref;
13264 }
13265
13266 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_ptr) {
13267         LDKChannelPublicKeys this_ptr_conv;
13268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13269         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13270         ChannelPublicKeys_free(this_ptr_conv);
13271 }
13272
13273 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
13274         LDKChannelPublicKeys orig_conv;
13275         orig_conv.inner = (void*)(orig & (~1));
13276         orig_conv.is_owned = false;
13277         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
13278         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13279         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13280         long ret_ref = (long)ret_var.inner;
13281         if (ret_var.is_owned) {
13282                 ret_ref |= 1;
13283         }
13284         return ret_ref;
13285 }
13286
13287 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
13288         LDKChannelPublicKeys this_ptr_conv;
13289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13290         this_ptr_conv.is_owned = false;
13291         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13292         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
13293         return arg_arr;
13294 }
13295
13296 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
13297         LDKChannelPublicKeys this_ptr_conv;
13298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13299         this_ptr_conv.is_owned = false;
13300         LDKPublicKey val_ref;
13301         CHECK(*((uint32_t*)val) == 33);
13302         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13303         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
13304 }
13305
13306 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
13307         LDKChannelPublicKeys this_ptr_conv;
13308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13309         this_ptr_conv.is_owned = false;
13310         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13311         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
13312         return arg_arr;
13313 }
13314
13315 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
13316         LDKChannelPublicKeys this_ptr_conv;
13317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13318         this_ptr_conv.is_owned = false;
13319         LDKPublicKey val_ref;
13320         CHECK(*((uint32_t*)val) == 33);
13321         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13322         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
13323 }
13324
13325 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
13326         LDKChannelPublicKeys this_ptr_conv;
13327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13328         this_ptr_conv.is_owned = false;
13329         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13330         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
13331         return arg_arr;
13332 }
13333
13334 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
13335         LDKChannelPublicKeys this_ptr_conv;
13336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13337         this_ptr_conv.is_owned = false;
13338         LDKPublicKey val_ref;
13339         CHECK(*((uint32_t*)val) == 33);
13340         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13341         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
13342 }
13343
13344 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
13345         LDKChannelPublicKeys this_ptr_conv;
13346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13347         this_ptr_conv.is_owned = false;
13348         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13349         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
13350         return arg_arr;
13351 }
13352
13353 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
13354         LDKChannelPublicKeys this_ptr_conv;
13355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13356         this_ptr_conv.is_owned = false;
13357         LDKPublicKey val_ref;
13358         CHECK(*((uint32_t*)val) == 33);
13359         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13360         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13361 }
13362
13363 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
13364         LDKChannelPublicKeys this_ptr_conv;
13365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13366         this_ptr_conv.is_owned = false;
13367         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13368         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
13369         return arg_arr;
13370 }
13371
13372 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
13373         LDKChannelPublicKeys this_ptr_conv;
13374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13375         this_ptr_conv.is_owned = false;
13376         LDKPublicKey val_ref;
13377         CHECK(*((uint32_t*)val) == 33);
13378         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13379         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
13380 }
13381
13382 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) {
13383         LDKPublicKey funding_pubkey_arg_ref;
13384         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
13385         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
13386         LDKPublicKey revocation_basepoint_arg_ref;
13387         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
13388         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
13389         LDKPublicKey payment_point_arg_ref;
13390         CHECK(*((uint32_t*)payment_point_arg) == 33);
13391         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
13392         LDKPublicKey delayed_payment_basepoint_arg_ref;
13393         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
13394         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
13395         LDKPublicKey htlc_basepoint_arg_ref;
13396         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
13397         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
13398         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);
13399         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13400         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13401         long ret_ref = (long)ret_var.inner;
13402         if (ret_var.is_owned) {
13403                 ret_ref |= 1;
13404         }
13405         return ret_ref;
13406 }
13407
13408 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
13409         LDKChannelPublicKeys obj_conv;
13410         obj_conv.inner = (void*)(obj & (~1));
13411         obj_conv.is_owned = false;
13412         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
13413         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13414         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13415         CVec_u8Z_free(arg_var);
13416         return arg_arr;
13417 }
13418
13419 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
13420         LDKu8slice ser_ref;
13421         ser_ref.datalen = *((uint32_t*)ser);
13422         ser_ref.data = (int8_t*)(ser + 4);
13423         LDKChannelPublicKeys ret_var = ChannelPublicKeys_read(ser_ref);
13424         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13425         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13426         long ret_ref = (long)ret_var.inner;
13427         if (ret_var.is_owned) {
13428                 ret_ref |= 1;
13429         }
13430         return ret_ref;
13431 }
13432
13433 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) {
13434         LDKPublicKey per_commitment_point_ref;
13435         CHECK(*((uint32_t*)per_commitment_point) == 33);
13436         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13437         LDKPublicKey broadcaster_delayed_payment_base_ref;
13438         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
13439         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
13440         LDKPublicKey broadcaster_htlc_base_ref;
13441         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
13442         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
13443         LDKPublicKey countersignatory_revocation_base_ref;
13444         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
13445         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
13446         LDKPublicKey countersignatory_htlc_base_ref;
13447         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
13448         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
13449         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13450         *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);
13451         return (long)ret_conv;
13452 }
13453
13454 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
13455         LDKPublicKey per_commitment_point_ref;
13456         CHECK(*((uint32_t*)per_commitment_point) == 33);
13457         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13458         LDKChannelPublicKeys broadcaster_keys_conv;
13459         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
13460         broadcaster_keys_conv.is_owned = false;
13461         LDKChannelPublicKeys countersignatory_keys_conv;
13462         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
13463         countersignatory_keys_conv.is_owned = false;
13464         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13465         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
13466         return (long)ret_conv;
13467 }
13468
13469 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
13470         LDKPublicKey revocation_key_ref;
13471         CHECK(*((uint32_t*)revocation_key) == 33);
13472         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13473         LDKPublicKey broadcaster_delayed_payment_key_ref;
13474         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13475         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13476         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
13477         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13478         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13479         CVec_u8Z_free(arg_var);
13480         return arg_arr;
13481 }
13482
13483 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_ptr) {
13484         LDKHTLCOutputInCommitment this_ptr_conv;
13485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13486         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13487         HTLCOutputInCommitment_free(this_ptr_conv);
13488 }
13489
13490 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
13491         LDKHTLCOutputInCommitment orig_conv;
13492         orig_conv.inner = (void*)(orig & (~1));
13493         orig_conv.is_owned = false;
13494         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
13495         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13496         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13497         long ret_ref = (long)ret_var.inner;
13498         if (ret_var.is_owned) {
13499                 ret_ref |= 1;
13500         }
13501         return ret_ref;
13502 }
13503
13504 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
13505         LDKHTLCOutputInCommitment this_ptr_conv;
13506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13507         this_ptr_conv.is_owned = false;
13508         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
13509         return ret_val;
13510 }
13511
13512 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
13513         LDKHTLCOutputInCommitment this_ptr_conv;
13514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13515         this_ptr_conv.is_owned = false;
13516         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
13517 }
13518
13519 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
13520         LDKHTLCOutputInCommitment this_ptr_conv;
13521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13522         this_ptr_conv.is_owned = false;
13523         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
13524         return ret_val;
13525 }
13526
13527 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
13528         LDKHTLCOutputInCommitment this_ptr_conv;
13529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13530         this_ptr_conv.is_owned = false;
13531         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
13532 }
13533
13534 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
13535         LDKHTLCOutputInCommitment this_ptr_conv;
13536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13537         this_ptr_conv.is_owned = false;
13538         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
13539         return ret_val;
13540 }
13541
13542 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
13543         LDKHTLCOutputInCommitment this_ptr_conv;
13544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13545         this_ptr_conv.is_owned = false;
13546         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
13547 }
13548
13549 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
13550         LDKHTLCOutputInCommitment this_ptr_conv;
13551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13552         this_ptr_conv.is_owned = false;
13553         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13554         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
13555         return ret_arr;
13556 }
13557
13558 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
13559         LDKHTLCOutputInCommitment this_ptr_conv;
13560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13561         this_ptr_conv.is_owned = false;
13562         LDKThirtyTwoBytes val_ref;
13563         CHECK(*((uint32_t*)val) == 32);
13564         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13565         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
13566 }
13567
13568 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
13569         LDKHTLCOutputInCommitment obj_conv;
13570         obj_conv.inner = (void*)(obj & (~1));
13571         obj_conv.is_owned = false;
13572         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
13573         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13574         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13575         CVec_u8Z_free(arg_var);
13576         return arg_arr;
13577 }
13578
13579 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
13580         LDKu8slice ser_ref;
13581         ser_ref.datalen = *((uint32_t*)ser);
13582         ser_ref.data = (int8_t*)(ser + 4);
13583         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_read(ser_ref);
13584         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13585         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13586         long ret_ref = (long)ret_var.inner;
13587         if (ret_var.is_owned) {
13588                 ret_ref |= 1;
13589         }
13590         return ret_ref;
13591 }
13592
13593 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
13594         LDKHTLCOutputInCommitment htlc_conv;
13595         htlc_conv.inner = (void*)(htlc & (~1));
13596         htlc_conv.is_owned = false;
13597         LDKTxCreationKeys keys_conv;
13598         keys_conv.inner = (void*)(keys & (~1));
13599         keys_conv.is_owned = false;
13600         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
13601         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13602         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13603         CVec_u8Z_free(arg_var);
13604         return arg_arr;
13605 }
13606
13607 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
13608         LDKPublicKey broadcaster_ref;
13609         CHECK(*((uint32_t*)broadcaster) == 33);
13610         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
13611         LDKPublicKey countersignatory_ref;
13612         CHECK(*((uint32_t*)countersignatory) == 33);
13613         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
13614         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
13615         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13616         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13617         CVec_u8Z_free(arg_var);
13618         return arg_arr;
13619 }
13620
13621 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) {
13622         unsigned char prev_hash_arr[32];
13623         CHECK(*((uint32_t*)prev_hash) == 32);
13624         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
13625         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
13626         LDKHTLCOutputInCommitment htlc_conv;
13627         htlc_conv.inner = (void*)(htlc & (~1));
13628         htlc_conv.is_owned = false;
13629         LDKPublicKey broadcaster_delayed_payment_key_ref;
13630         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13631         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13632         LDKPublicKey revocation_key_ref;
13633         CHECK(*((uint32_t*)revocation_key) == 33);
13634         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13635         LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
13636         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13637         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13638         Transaction_free(arg_var);
13639         return arg_arr;
13640 }
13641
13642 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_ptr) {
13643         LDKChannelTransactionParameters this_ptr_conv;
13644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13645         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13646         ChannelTransactionParameters_free(this_ptr_conv);
13647 }
13648
13649 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
13650         LDKChannelTransactionParameters orig_conv;
13651         orig_conv.inner = (void*)(orig & (~1));
13652         orig_conv.is_owned = false;
13653         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
13654         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13655         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13656         long ret_ref = (long)ret_var.inner;
13657         if (ret_var.is_owned) {
13658                 ret_ref |= 1;
13659         }
13660         return ret_ref;
13661 }
13662
13663 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
13664         LDKChannelTransactionParameters this_ptr_conv;
13665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13666         this_ptr_conv.is_owned = false;
13667         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
13668         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13669         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13670         long ret_ref = (long)ret_var.inner;
13671         if (ret_var.is_owned) {
13672                 ret_ref |= 1;
13673         }
13674         return ret_ref;
13675 }
13676
13677 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
13678         LDKChannelTransactionParameters this_ptr_conv;
13679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13680         this_ptr_conv.is_owned = false;
13681         LDKChannelPublicKeys val_conv;
13682         val_conv.inner = (void*)(val & (~1));
13683         val_conv.is_owned = (val & 1) || (val == 0);
13684         if (val_conv.inner != NULL)
13685                 val_conv = ChannelPublicKeys_clone(&val_conv);
13686         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
13687 }
13688
13689 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
13690         LDKChannelTransactionParameters this_ptr_conv;
13691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13692         this_ptr_conv.is_owned = false;
13693         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
13694         return ret_val;
13695 }
13696
13697 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13698         LDKChannelTransactionParameters this_ptr_conv;
13699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13700         this_ptr_conv.is_owned = false;
13701         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
13702 }
13703
13704 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
13705         LDKChannelTransactionParameters this_ptr_conv;
13706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13707         this_ptr_conv.is_owned = false;
13708         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
13709         return ret_val;
13710 }
13711
13712 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
13713         LDKChannelTransactionParameters this_ptr_conv;
13714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13715         this_ptr_conv.is_owned = false;
13716         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
13717 }
13718
13719 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
13720         LDKChannelTransactionParameters this_ptr_conv;
13721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13722         this_ptr_conv.is_owned = false;
13723         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
13724         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13725         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13726         long ret_ref = (long)ret_var.inner;
13727         if (ret_var.is_owned) {
13728                 ret_ref |= 1;
13729         }
13730         return ret_ref;
13731 }
13732
13733 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
13734         LDKChannelTransactionParameters this_ptr_conv;
13735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13736         this_ptr_conv.is_owned = false;
13737         LDKCounterpartyChannelTransactionParameters val_conv;
13738         val_conv.inner = (void*)(val & (~1));
13739         val_conv.is_owned = (val & 1) || (val == 0);
13740         if (val_conv.inner != NULL)
13741                 val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
13742         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
13743 }
13744
13745 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
13746         LDKChannelTransactionParameters this_ptr_conv;
13747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13748         this_ptr_conv.is_owned = false;
13749         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
13750         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13751         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13752         long ret_ref = (long)ret_var.inner;
13753         if (ret_var.is_owned) {
13754                 ret_ref |= 1;
13755         }
13756         return ret_ref;
13757 }
13758
13759 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
13760         LDKChannelTransactionParameters this_ptr_conv;
13761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13762         this_ptr_conv.is_owned = false;
13763         LDKOutPoint val_conv;
13764         val_conv.inner = (void*)(val & (~1));
13765         val_conv.is_owned = (val & 1) || (val == 0);
13766         if (val_conv.inner != NULL)
13767                 val_conv = OutPoint_clone(&val_conv);
13768         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
13769 }
13770
13771 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) {
13772         LDKChannelPublicKeys holder_pubkeys_arg_conv;
13773         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
13774         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
13775         if (holder_pubkeys_arg_conv.inner != NULL)
13776                 holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
13777         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
13778         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
13779         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
13780         if (counterparty_parameters_arg_conv.inner != NULL)
13781                 counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
13782         LDKOutPoint funding_outpoint_arg_conv;
13783         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
13784         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
13785         if (funding_outpoint_arg_conv.inner != NULL)
13786                 funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
13787         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);
13788         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13789         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13790         long ret_ref = (long)ret_var.inner;
13791         if (ret_var.is_owned) {
13792                 ret_ref |= 1;
13793         }
13794         return ret_ref;
13795 }
13796
13797 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_ptr) {
13798         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13800         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13801         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
13802 }
13803
13804 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
13805         LDKCounterpartyChannelTransactionParameters orig_conv;
13806         orig_conv.inner = (void*)(orig & (~1));
13807         orig_conv.is_owned = false;
13808         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
13809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13811         long ret_ref = (long)ret_var.inner;
13812         if (ret_var.is_owned) {
13813                 ret_ref |= 1;
13814         }
13815         return ret_ref;
13816 }
13817
13818 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
13819         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13821         this_ptr_conv.is_owned = false;
13822         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
13823         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13824         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13825         long ret_ref = (long)ret_var.inner;
13826         if (ret_var.is_owned) {
13827                 ret_ref |= 1;
13828         }
13829         return ret_ref;
13830 }
13831
13832 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
13833         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13835         this_ptr_conv.is_owned = false;
13836         LDKChannelPublicKeys val_conv;
13837         val_conv.inner = (void*)(val & (~1));
13838         val_conv.is_owned = (val & 1) || (val == 0);
13839         if (val_conv.inner != NULL)
13840                 val_conv = ChannelPublicKeys_clone(&val_conv);
13841         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
13842 }
13843
13844 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
13845         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13847         this_ptr_conv.is_owned = false;
13848         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
13849         return ret_val;
13850 }
13851
13852 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13853         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13855         this_ptr_conv.is_owned = false;
13856         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
13857 }
13858
13859 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
13860         LDKChannelPublicKeys pubkeys_arg_conv;
13861         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
13862         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
13863         if (pubkeys_arg_conv.inner != NULL)
13864                 pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
13865         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
13866         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13867         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13868         long ret_ref = (long)ret_var.inner;
13869         if (ret_var.is_owned) {
13870                 ret_ref |= 1;
13871         }
13872         return ret_ref;
13873 }
13874
13875 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
13876         LDKChannelTransactionParameters this_arg_conv;
13877         this_arg_conv.inner = (void*)(this_arg & (~1));
13878         this_arg_conv.is_owned = false;
13879         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
13880         return ret_val;
13881 }
13882
13883 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
13884         LDKChannelTransactionParameters this_arg_conv;
13885         this_arg_conv.inner = (void*)(this_arg & (~1));
13886         this_arg_conv.is_owned = false;
13887         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
13888         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13889         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13890         long ret_ref = (long)ret_var.inner;
13891         if (ret_var.is_owned) {
13892                 ret_ref |= 1;
13893         }
13894         return ret_ref;
13895 }
13896
13897 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
13898         LDKChannelTransactionParameters this_arg_conv;
13899         this_arg_conv.inner = (void*)(this_arg & (~1));
13900         this_arg_conv.is_owned = false;
13901         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
13902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13904         long ret_ref = (long)ret_var.inner;
13905         if (ret_var.is_owned) {
13906                 ret_ref |= 1;
13907         }
13908         return ret_ref;
13909 }
13910
13911 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
13912         LDKCounterpartyChannelTransactionParameters obj_conv;
13913         obj_conv.inner = (void*)(obj & (~1));
13914         obj_conv.is_owned = false;
13915         LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
13916         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13917         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13918         CVec_u8Z_free(arg_var);
13919         return arg_arr;
13920 }
13921
13922 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
13923         LDKu8slice ser_ref;
13924         ser_ref.datalen = *((uint32_t*)ser);
13925         ser_ref.data = (int8_t*)(ser + 4);
13926         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_read(ser_ref);
13927         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13928         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13929         long ret_ref = (long)ret_var.inner;
13930         if (ret_var.is_owned) {
13931                 ret_ref |= 1;
13932         }
13933         return ret_ref;
13934 }
13935
13936 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
13937         LDKChannelTransactionParameters obj_conv;
13938         obj_conv.inner = (void*)(obj & (~1));
13939         obj_conv.is_owned = false;
13940         LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
13941         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13942         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13943         CVec_u8Z_free(arg_var);
13944         return arg_arr;
13945 }
13946
13947 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
13948         LDKu8slice ser_ref;
13949         ser_ref.datalen = *((uint32_t*)ser);
13950         ser_ref.data = (int8_t*)(ser + 4);
13951         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_read(ser_ref);
13952         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13953         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13954         long ret_ref = (long)ret_var.inner;
13955         if (ret_var.is_owned) {
13956                 ret_ref |= 1;
13957         }
13958         return ret_ref;
13959 }
13960
13961 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_ptr) {
13962         LDKDirectedChannelTransactionParameters this_ptr_conv;
13963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13964         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13965         DirectedChannelTransactionParameters_free(this_ptr_conv);
13966 }
13967
13968 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
13969         LDKDirectedChannelTransactionParameters this_arg_conv;
13970         this_arg_conv.inner = (void*)(this_arg & (~1));
13971         this_arg_conv.is_owned = false;
13972         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
13973         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13974         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13975         long ret_ref = (long)ret_var.inner;
13976         if (ret_var.is_owned) {
13977                 ret_ref |= 1;
13978         }
13979         return ret_ref;
13980 }
13981
13982 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
13983         LDKDirectedChannelTransactionParameters this_arg_conv;
13984         this_arg_conv.inner = (void*)(this_arg & (~1));
13985         this_arg_conv.is_owned = false;
13986         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
13987         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13988         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13989         long ret_ref = (long)ret_var.inner;
13990         if (ret_var.is_owned) {
13991                 ret_ref |= 1;
13992         }
13993         return ret_ref;
13994 }
13995
13996 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
13997         LDKDirectedChannelTransactionParameters this_arg_conv;
13998         this_arg_conv.inner = (void*)(this_arg & (~1));
13999         this_arg_conv.is_owned = false;
14000         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
14001         return ret_val;
14002 }
14003
14004 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
14005         LDKDirectedChannelTransactionParameters this_arg_conv;
14006         this_arg_conv.inner = (void*)(this_arg & (~1));
14007         this_arg_conv.is_owned = false;
14008         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
14009         return ret_val;
14010 }
14011
14012 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
14013         LDKDirectedChannelTransactionParameters this_arg_conv;
14014         this_arg_conv.inner = (void*)(this_arg & (~1));
14015         this_arg_conv.is_owned = false;
14016         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
14017         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14018         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14019         long ret_ref = (long)ret_var.inner;
14020         if (ret_var.is_owned) {
14021                 ret_ref |= 1;
14022         }
14023         return ret_ref;
14024 }
14025
14026 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_ptr) {
14027         LDKHolderCommitmentTransaction this_ptr_conv;
14028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14029         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14030         HolderCommitmentTransaction_free(this_ptr_conv);
14031 }
14032
14033 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
14034         LDKHolderCommitmentTransaction orig_conv;
14035         orig_conv.inner = (void*)(orig & (~1));
14036         orig_conv.is_owned = false;
14037         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
14038         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14039         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14040         long ret_ref = (long)ret_var.inner;
14041         if (ret_var.is_owned) {
14042                 ret_ref |= 1;
14043         }
14044         return ret_ref;
14045 }
14046
14047 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
14048         LDKHolderCommitmentTransaction this_ptr_conv;
14049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14050         this_ptr_conv.is_owned = false;
14051         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14052         memcpy((uint8_t*)(arg_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
14053         return arg_arr;
14054 }
14055
14056 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
14057         LDKHolderCommitmentTransaction this_ptr_conv;
14058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14059         this_ptr_conv.is_owned = false;
14060         LDKSignature val_ref;
14061         CHECK(*((uint32_t*)val) == 64);
14062         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14063         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
14064 }
14065
14066 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
14067         LDKHolderCommitmentTransaction this_ptr_conv;
14068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14069         this_ptr_conv.is_owned = false;
14070         LDKCVec_SignatureZ val_constr;
14071         val_constr.datalen = *((uint32_t*)val);
14072         if (val_constr.datalen > 0)
14073                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14074         else
14075                 val_constr.data = NULL;
14076         int8_tArray* val_vals = (int8_tArray*)(val + 4);
14077         for (size_t m = 0; m < val_constr.datalen; m++) {
14078                 int8_tArray arr_conv_12 = val_vals[m];
14079                 LDKSignature arr_conv_12_ref;
14080                 CHECK(*((uint32_t*)arr_conv_12) == 64);
14081                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14082                 val_constr.data[m] = arr_conv_12_ref;
14083         }
14084         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
14085 }
14086
14087 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
14088         LDKHolderCommitmentTransaction obj_conv;
14089         obj_conv.inner = (void*)(obj & (~1));
14090         obj_conv.is_owned = false;
14091         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
14092         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14093         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14094         CVec_u8Z_free(arg_var);
14095         return arg_arr;
14096 }
14097
14098 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
14099         LDKu8slice ser_ref;
14100         ser_ref.datalen = *((uint32_t*)ser);
14101         ser_ref.data = (int8_t*)(ser + 4);
14102         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_read(ser_ref);
14103         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14104         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14105         long ret_ref = (long)ret_var.inner;
14106         if (ret_var.is_owned) {
14107                 ret_ref |= 1;
14108         }
14109         return ret_ref;
14110 }
14111
14112 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) {
14113         LDKCommitmentTransaction commitment_tx_conv;
14114         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
14115         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
14116         if (commitment_tx_conv.inner != NULL)
14117                 commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
14118         LDKSignature counterparty_sig_ref;
14119         CHECK(*((uint32_t*)counterparty_sig) == 64);
14120         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
14121         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
14122         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
14123         if (counterparty_htlc_sigs_constr.datalen > 0)
14124                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14125         else
14126                 counterparty_htlc_sigs_constr.data = NULL;
14127         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
14128         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
14129                 int8_tArray arr_conv_12 = counterparty_htlc_sigs_vals[m];
14130                 LDKSignature arr_conv_12_ref;
14131                 CHECK(*((uint32_t*)arr_conv_12) == 64);
14132                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14133                 counterparty_htlc_sigs_constr.data[m] = arr_conv_12_ref;
14134         }
14135         LDKPublicKey holder_funding_key_ref;
14136         CHECK(*((uint32_t*)holder_funding_key) == 33);
14137         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
14138         LDKPublicKey counterparty_funding_key_ref;
14139         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
14140         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
14141         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
14142         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14143         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14144         long ret_ref = (long)ret_var.inner;
14145         if (ret_var.is_owned) {
14146                 ret_ref |= 1;
14147         }
14148         return ret_ref;
14149 }
14150
14151 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_ptr) {
14152         LDKBuiltCommitmentTransaction this_ptr_conv;
14153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14154         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14155         BuiltCommitmentTransaction_free(this_ptr_conv);
14156 }
14157
14158 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
14159         LDKBuiltCommitmentTransaction orig_conv;
14160         orig_conv.inner = (void*)(orig & (~1));
14161         orig_conv.is_owned = false;
14162         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
14163         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14164         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14165         long ret_ref = (long)ret_var.inner;
14166         if (ret_var.is_owned) {
14167                 ret_ref |= 1;
14168         }
14169         return ret_ref;
14170 }
14171
14172 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
14173         LDKBuiltCommitmentTransaction this_ptr_conv;
14174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14175         this_ptr_conv.is_owned = false;
14176         LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
14177         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14178         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14179         Transaction_free(arg_var);
14180         return arg_arr;
14181 }
14182
14183 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
14184         LDKBuiltCommitmentTransaction this_ptr_conv;
14185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14186         this_ptr_conv.is_owned = false;
14187         LDKTransaction val_ref;
14188         val_ref.datalen = *((uint32_t*)val);
14189         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
14190         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14191         val_ref.data_is_owned = true;
14192         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
14193 }
14194
14195 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
14196         LDKBuiltCommitmentTransaction this_ptr_conv;
14197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14198         this_ptr_conv.is_owned = false;
14199         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14200         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
14201         return ret_arr;
14202 }
14203
14204 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
14205         LDKBuiltCommitmentTransaction this_ptr_conv;
14206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14207         this_ptr_conv.is_owned = false;
14208         LDKThirtyTwoBytes val_ref;
14209         CHECK(*((uint32_t*)val) == 32);
14210         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14211         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
14212 }
14213
14214 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
14215         LDKTransaction transaction_arg_ref;
14216         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
14217         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
14218         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
14219         transaction_arg_ref.data_is_owned = true;
14220         LDKThirtyTwoBytes txid_arg_ref;
14221         CHECK(*((uint32_t*)txid_arg) == 32);
14222         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
14223         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
14224         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14225         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14226         long ret_ref = (long)ret_var.inner;
14227         if (ret_var.is_owned) {
14228                 ret_ref |= 1;
14229         }
14230         return ret_ref;
14231 }
14232
14233 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
14234         LDKBuiltCommitmentTransaction obj_conv;
14235         obj_conv.inner = (void*)(obj & (~1));
14236         obj_conv.is_owned = false;
14237         LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
14238         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14239         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14240         CVec_u8Z_free(arg_var);
14241         return arg_arr;
14242 }
14243
14244 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
14245         LDKu8slice ser_ref;
14246         ser_ref.datalen = *((uint32_t*)ser);
14247         ser_ref.data = (int8_t*)(ser + 4);
14248         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_read(ser_ref);
14249         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14250         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14251         long ret_ref = (long)ret_var.inner;
14252         if (ret_var.is_owned) {
14253                 ret_ref |= 1;
14254         }
14255         return ret_ref;
14256 }
14257
14258 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
14259         LDKBuiltCommitmentTransaction this_arg_conv;
14260         this_arg_conv.inner = (void*)(this_arg & (~1));
14261         this_arg_conv.is_owned = false;
14262         LDKu8slice funding_redeemscript_ref;
14263         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14264         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14265         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14266         memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
14267         return arg_arr;
14268 }
14269
14270 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) {
14271         LDKBuiltCommitmentTransaction this_arg_conv;
14272         this_arg_conv.inner = (void*)(this_arg & (~1));
14273         this_arg_conv.is_owned = false;
14274         unsigned char funding_key_arr[32];
14275         CHECK(*((uint32_t*)funding_key) == 32);
14276         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
14277         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
14278         LDKu8slice funding_redeemscript_ref;
14279         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14280         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14281         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14282         memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
14283         return arg_arr;
14284 }
14285
14286 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_ptr) {
14287         LDKCommitmentTransaction this_ptr_conv;
14288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14289         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14290         CommitmentTransaction_free(this_ptr_conv);
14291 }
14292
14293 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
14294         LDKCommitmentTransaction orig_conv;
14295         orig_conv.inner = (void*)(orig & (~1));
14296         orig_conv.is_owned = false;
14297         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
14298         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14299         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14300         long ret_ref = (long)ret_var.inner;
14301         if (ret_var.is_owned) {
14302                 ret_ref |= 1;
14303         }
14304         return ret_ref;
14305 }
14306
14307 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
14308         LDKCommitmentTransaction obj_conv;
14309         obj_conv.inner = (void*)(obj & (~1));
14310         obj_conv.is_owned = false;
14311         LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
14312         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14313         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14314         CVec_u8Z_free(arg_var);
14315         return arg_arr;
14316 }
14317
14318 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
14319         LDKu8slice ser_ref;
14320         ser_ref.datalen = *((uint32_t*)ser);
14321         ser_ref.data = (int8_t*)(ser + 4);
14322         LDKCommitmentTransaction ret_var = CommitmentTransaction_read(ser_ref);
14323         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14324         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14325         long ret_ref = (long)ret_var.inner;
14326         if (ret_var.is_owned) {
14327                 ret_ref |= 1;
14328         }
14329         return ret_ref;
14330 }
14331
14332 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
14333         LDKCommitmentTransaction this_arg_conv;
14334         this_arg_conv.inner = (void*)(this_arg & (~1));
14335         this_arg_conv.is_owned = false;
14336         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
14337         return ret_val;
14338 }
14339
14340 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
14341         LDKCommitmentTransaction this_arg_conv;
14342         this_arg_conv.inner = (void*)(this_arg & (~1));
14343         this_arg_conv.is_owned = false;
14344         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
14345         return ret_val;
14346 }
14347
14348 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
14349         LDKCommitmentTransaction this_arg_conv;
14350         this_arg_conv.inner = (void*)(this_arg & (~1));
14351         this_arg_conv.is_owned = false;
14352         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
14353         return ret_val;
14354 }
14355
14356 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
14357         LDKCommitmentTransaction this_arg_conv;
14358         this_arg_conv.inner = (void*)(this_arg & (~1));
14359         this_arg_conv.is_owned = false;
14360         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
14361         return ret_val;
14362 }
14363
14364 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
14365         LDKCommitmentTransaction this_arg_conv;
14366         this_arg_conv.inner = (void*)(this_arg & (~1));
14367         this_arg_conv.is_owned = false;
14368         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
14369         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14370         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14371         long ret_ref = (long)ret_var.inner;
14372         if (ret_var.is_owned) {
14373                 ret_ref |= 1;
14374         }
14375         return ret_ref;
14376 }
14377
14378 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
14379         LDKCommitmentTransaction this_arg_conv;
14380         this_arg_conv.inner = (void*)(this_arg & (~1));
14381         this_arg_conv.is_owned = false;
14382         LDKDirectedChannelTransactionParameters channel_parameters_conv;
14383         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14384         channel_parameters_conv.is_owned = false;
14385         LDKChannelPublicKeys broadcaster_keys_conv;
14386         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
14387         broadcaster_keys_conv.is_owned = false;
14388         LDKChannelPublicKeys countersignatory_keys_conv;
14389         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
14390         countersignatory_keys_conv.is_owned = false;
14391         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14392         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
14393         return (long)ret_conv;
14394 }
14395
14396 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_ptr) {
14397         LDKTrustedCommitmentTransaction this_ptr_conv;
14398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14400         TrustedCommitmentTransaction_free(this_ptr_conv);
14401 }
14402
14403 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
14404         LDKTrustedCommitmentTransaction this_arg_conv;
14405         this_arg_conv.inner = (void*)(this_arg & (~1));
14406         this_arg_conv.is_owned = false;
14407         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14408         memcpy((uint8_t*)(arg_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
14409         return arg_arr;
14410 }
14411
14412 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
14413         LDKTrustedCommitmentTransaction this_arg_conv;
14414         this_arg_conv.inner = (void*)(this_arg & (~1));
14415         this_arg_conv.is_owned = false;
14416         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
14417         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14418         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14419         long ret_ref = (long)ret_var.inner;
14420         if (ret_var.is_owned) {
14421                 ret_ref |= 1;
14422         }
14423         return ret_ref;
14424 }
14425
14426 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
14427         LDKTrustedCommitmentTransaction this_arg_conv;
14428         this_arg_conv.inner = (void*)(this_arg & (~1));
14429         this_arg_conv.is_owned = false;
14430         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
14431         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14432         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14433         long ret_ref = (long)ret_var.inner;
14434         if (ret_var.is_owned) {
14435                 ret_ref |= 1;
14436         }
14437         return ret_ref;
14438 }
14439
14440 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
14441         LDKTrustedCommitmentTransaction this_arg_conv;
14442         this_arg_conv.inner = (void*)(this_arg & (~1));
14443         this_arg_conv.is_owned = false;
14444         unsigned char htlc_base_key_arr[32];
14445         CHECK(*((uint32_t*)htlc_base_key) == 32);
14446         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
14447         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
14448         LDKDirectedChannelTransactionParameters channel_parameters_conv;
14449         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14450         channel_parameters_conv.is_owned = false;
14451         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14452         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
14453         return (long)ret_conv;
14454 }
14455
14456 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) {
14457         LDKPublicKey broadcaster_payment_basepoint_ref;
14458         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
14459         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
14460         LDKPublicKey countersignatory_payment_basepoint_ref;
14461         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
14462         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
14463         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
14464         return ret_val;
14465 }
14466
14467 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_ptr) {
14468         LDKInitFeatures this_ptr_conv;
14469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14470         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14471         InitFeatures_free(this_ptr_conv);
14472 }
14473
14474 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_ptr) {
14475         LDKNodeFeatures this_ptr_conv;
14476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14478         NodeFeatures_free(this_ptr_conv);
14479 }
14480
14481 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_ptr) {
14482         LDKChannelFeatures this_ptr_conv;
14483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14484         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14485         ChannelFeatures_free(this_ptr_conv);
14486 }
14487
14488 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_ptr) {
14489         LDKRouteHop this_ptr_conv;
14490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14491         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14492         RouteHop_free(this_ptr_conv);
14493 }
14494
14495 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
14496         LDKRouteHop orig_conv;
14497         orig_conv.inner = (void*)(orig & (~1));
14498         orig_conv.is_owned = false;
14499         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
14500         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14501         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14502         long ret_ref = (long)ret_var.inner;
14503         if (ret_var.is_owned) {
14504                 ret_ref |= 1;
14505         }
14506         return ret_ref;
14507 }
14508
14509 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
14510         LDKRouteHop this_ptr_conv;
14511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14512         this_ptr_conv.is_owned = false;
14513         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14514         memcpy((uint8_t*)(arg_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
14515         return arg_arr;
14516 }
14517
14518 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
14519         LDKRouteHop this_ptr_conv;
14520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14521         this_ptr_conv.is_owned = false;
14522         LDKPublicKey val_ref;
14523         CHECK(*((uint32_t*)val) == 33);
14524         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14525         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
14526 }
14527
14528 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
14529         LDKRouteHop this_ptr_conv;
14530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14531         this_ptr_conv.is_owned = false;
14532         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
14533         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14534         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14535         long ret_ref = (long)ret_var.inner;
14536         if (ret_var.is_owned) {
14537                 ret_ref |= 1;
14538         }
14539         return ret_ref;
14540 }
14541
14542 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
14543         LDKRouteHop this_ptr_conv;
14544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14545         this_ptr_conv.is_owned = false;
14546         LDKNodeFeatures val_conv;
14547         val_conv.inner = (void*)(val & (~1));
14548         val_conv.is_owned = (val & 1) || (val == 0);
14549         // Warning: we may need a move here but can't clone!
14550         RouteHop_set_node_features(&this_ptr_conv, val_conv);
14551 }
14552
14553 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
14554         LDKRouteHop this_ptr_conv;
14555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14556         this_ptr_conv.is_owned = false;
14557         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
14558         return ret_val;
14559 }
14560
14561 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14562         LDKRouteHop this_ptr_conv;
14563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14564         this_ptr_conv.is_owned = false;
14565         RouteHop_set_short_channel_id(&this_ptr_conv, val);
14566 }
14567
14568 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
14569         LDKRouteHop this_ptr_conv;
14570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14571         this_ptr_conv.is_owned = false;
14572         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
14573         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14574         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14575         long ret_ref = (long)ret_var.inner;
14576         if (ret_var.is_owned) {
14577                 ret_ref |= 1;
14578         }
14579         return ret_ref;
14580 }
14581
14582 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
14583         LDKRouteHop this_ptr_conv;
14584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14585         this_ptr_conv.is_owned = false;
14586         LDKChannelFeatures val_conv;
14587         val_conv.inner = (void*)(val & (~1));
14588         val_conv.is_owned = (val & 1) || (val == 0);
14589         // Warning: we may need a move here but can't clone!
14590         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
14591 }
14592
14593 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
14594         LDKRouteHop this_ptr_conv;
14595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14596         this_ptr_conv.is_owned = false;
14597         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
14598         return ret_val;
14599 }
14600
14601 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
14602         LDKRouteHop this_ptr_conv;
14603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14604         this_ptr_conv.is_owned = false;
14605         RouteHop_set_fee_msat(&this_ptr_conv, val);
14606 }
14607
14608 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
14609         LDKRouteHop this_ptr_conv;
14610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14611         this_ptr_conv.is_owned = false;
14612         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
14613         return ret_val;
14614 }
14615
14616 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
14617         LDKRouteHop this_ptr_conv;
14618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14619         this_ptr_conv.is_owned = false;
14620         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
14621 }
14622
14623 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) {
14624         LDKPublicKey pubkey_arg_ref;
14625         CHECK(*((uint32_t*)pubkey_arg) == 33);
14626         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
14627         LDKNodeFeatures node_features_arg_conv;
14628         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
14629         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
14630         // Warning: we may need a move here but can't clone!
14631         LDKChannelFeatures channel_features_arg_conv;
14632         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
14633         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
14634         // Warning: we may need a move here but can't clone!
14635         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);
14636         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14637         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14638         long ret_ref = (long)ret_var.inner;
14639         if (ret_var.is_owned) {
14640                 ret_ref |= 1;
14641         }
14642         return ret_ref;
14643 }
14644
14645 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_ptr) {
14646         LDKRoute this_ptr_conv;
14647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14648         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14649         Route_free(this_ptr_conv);
14650 }
14651
14652 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
14653         LDKRoute orig_conv;
14654         orig_conv.inner = (void*)(orig & (~1));
14655         orig_conv.is_owned = false;
14656         LDKRoute ret_var = Route_clone(&orig_conv);
14657         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14658         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14659         long ret_ref = (long)ret_var.inner;
14660         if (ret_var.is_owned) {
14661                 ret_ref |= 1;
14662         }
14663         return ret_ref;
14664 }
14665
14666 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
14667         LDKRoute this_ptr_conv;
14668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14669         this_ptr_conv.is_owned = false;
14670         LDKCVec_CVec_RouteHopZZ val_constr;
14671         val_constr.datalen = *((uint32_t*)val);
14672         if (val_constr.datalen > 0)
14673                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14674         else
14675                 val_constr.data = NULL;
14676         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
14677         for (size_t m = 0; m < val_constr.datalen; m++) {
14678                 uint32_tArray arr_conv_12 = val_vals[m];
14679                 LDKCVec_RouteHopZ arr_conv_12_constr;
14680                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14681                 if (arr_conv_12_constr.datalen > 0)
14682                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14683                 else
14684                         arr_conv_12_constr.data = NULL;
14685                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14686                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14687                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
14688                         LDKRouteHop arr_conv_10_conv;
14689                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14690                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14691                         if (arr_conv_10_conv.inner != NULL)
14692                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14693                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
14694                 }
14695                 val_constr.data[m] = arr_conv_12_constr;
14696         }
14697         Route_set_paths(&this_ptr_conv, val_constr);
14698 }
14699
14700 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
14701         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
14702         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
14703         if (paths_arg_constr.datalen > 0)
14704                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14705         else
14706                 paths_arg_constr.data = NULL;
14707         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
14708         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
14709                 uint32_tArray arr_conv_12 = paths_arg_vals[m];
14710                 LDKCVec_RouteHopZ arr_conv_12_constr;
14711                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14712                 if (arr_conv_12_constr.datalen > 0)
14713                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14714                 else
14715                         arr_conv_12_constr.data = NULL;
14716                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14717                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14718                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
14719                         LDKRouteHop arr_conv_10_conv;
14720                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14721                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14722                         if (arr_conv_10_conv.inner != NULL)
14723                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14724                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
14725                 }
14726                 paths_arg_constr.data[m] = arr_conv_12_constr;
14727         }
14728         LDKRoute ret_var = Route_new(paths_arg_constr);
14729         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14730         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14731         long ret_ref = (long)ret_var.inner;
14732         if (ret_var.is_owned) {
14733                 ret_ref |= 1;
14734         }
14735         return ret_ref;
14736 }
14737
14738 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
14739         LDKRoute obj_conv;
14740         obj_conv.inner = (void*)(obj & (~1));
14741         obj_conv.is_owned = false;
14742         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
14743         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14744         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14745         CVec_u8Z_free(arg_var);
14746         return arg_arr;
14747 }
14748
14749 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
14750         LDKu8slice ser_ref;
14751         ser_ref.datalen = *((uint32_t*)ser);
14752         ser_ref.data = (int8_t*)(ser + 4);
14753         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14754         *ret_conv = Route_read(ser_ref);
14755         return (long)ret_conv;
14756 }
14757
14758 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_ptr) {
14759         LDKRouteHint this_ptr_conv;
14760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14761         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14762         RouteHint_free(this_ptr_conv);
14763 }
14764
14765 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
14766         LDKRouteHint orig_conv;
14767         orig_conv.inner = (void*)(orig & (~1));
14768         orig_conv.is_owned = false;
14769         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
14770         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14771         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14772         long ret_ref = (long)ret_var.inner;
14773         if (ret_var.is_owned) {
14774                 ret_ref |= 1;
14775         }
14776         return ret_ref;
14777 }
14778
14779 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
14780         LDKRouteHint this_ptr_conv;
14781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14782         this_ptr_conv.is_owned = false;
14783         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14784         memcpy((uint8_t*)(arg_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
14785         return arg_arr;
14786 }
14787
14788 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
14789         LDKRouteHint this_ptr_conv;
14790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14791         this_ptr_conv.is_owned = false;
14792         LDKPublicKey val_ref;
14793         CHECK(*((uint32_t*)val) == 33);
14794         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14795         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
14796 }
14797
14798 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
14799         LDKRouteHint this_ptr_conv;
14800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14801         this_ptr_conv.is_owned = false;
14802         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
14803         return ret_val;
14804 }
14805
14806 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14807         LDKRouteHint this_ptr_conv;
14808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14809         this_ptr_conv.is_owned = false;
14810         RouteHint_set_short_channel_id(&this_ptr_conv, val);
14811 }
14812
14813 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
14814         LDKRouteHint this_ptr_conv;
14815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14816         this_ptr_conv.is_owned = false;
14817         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
14818         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14819         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14820         long ret_ref = (long)ret_var.inner;
14821         if (ret_var.is_owned) {
14822                 ret_ref |= 1;
14823         }
14824         return ret_ref;
14825 }
14826
14827 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
14828         LDKRouteHint this_ptr_conv;
14829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14830         this_ptr_conv.is_owned = false;
14831         LDKRoutingFees val_conv;
14832         val_conv.inner = (void*)(val & (~1));
14833         val_conv.is_owned = (val & 1) || (val == 0);
14834         if (val_conv.inner != NULL)
14835                 val_conv = RoutingFees_clone(&val_conv);
14836         RouteHint_set_fees(&this_ptr_conv, val_conv);
14837 }
14838
14839 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
14840         LDKRouteHint this_ptr_conv;
14841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14842         this_ptr_conv.is_owned = false;
14843         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
14844         return ret_val;
14845 }
14846
14847 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14848         LDKRouteHint this_ptr_conv;
14849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14850         this_ptr_conv.is_owned = false;
14851         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
14852 }
14853
14854 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_minimum_msat(uint32_t this_ptr) {
14855         LDKRouteHint this_ptr_conv;
14856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14857         this_ptr_conv.is_owned = false;
14858         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
14859         return ret_val;
14860 }
14861
14862 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14863         LDKRouteHint this_ptr_conv;
14864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14865         this_ptr_conv.is_owned = false;
14866         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
14867 }
14868
14869 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg) {
14870         LDKPublicKey src_node_id_arg_ref;
14871         CHECK(*((uint32_t*)src_node_id_arg) == 33);
14872         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
14873         LDKRoutingFees fees_arg_conv;
14874         fees_arg_conv.inner = (void*)(fees_arg & (~1));
14875         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
14876         if (fees_arg_conv.inner != NULL)
14877                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
14878         LDKRouteHint ret_var = RouteHint_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg);
14879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14881         long ret_ref = (long)ret_var.inner;
14882         if (ret_var.is_owned) {
14883                 ret_ref |= 1;
14884         }
14885         return ret_ref;
14886 }
14887
14888 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray target, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
14889         LDKPublicKey our_node_id_ref;
14890         CHECK(*((uint32_t*)our_node_id) == 33);
14891         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
14892         LDKNetworkGraph network_conv;
14893         network_conv.inner = (void*)(network & (~1));
14894         network_conv.is_owned = false;
14895         LDKPublicKey target_ref;
14896         CHECK(*((uint32_t*)target) == 33);
14897         memcpy(target_ref.compressed_form, (uint8_t*)(target + 4), 33);
14898         LDKCVec_ChannelDetailsZ first_hops_constr;
14899         first_hops_constr.datalen = *((uint32_t*)first_hops);
14900         if (first_hops_constr.datalen > 0)
14901                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14902         else
14903                 first_hops_constr.data = NULL;
14904         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
14905         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14906                 uint32_t arr_conv_16 = first_hops_vals[q];
14907                 LDKChannelDetails arr_conv_16_conv;
14908                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
14909                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
14910                 first_hops_constr.data[q] = arr_conv_16_conv;
14911         }
14912         LDKCVec_RouteHintZ last_hops_constr;
14913         last_hops_constr.datalen = *((uint32_t*)last_hops);
14914         if (last_hops_constr.datalen > 0)
14915                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14916         else
14917                 last_hops_constr.data = NULL;
14918         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
14919         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
14920                 uint32_t arr_conv_11 = last_hops_vals[l];
14921                 LDKRouteHint arr_conv_11_conv;
14922                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
14923                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
14924                 if (arr_conv_11_conv.inner != NULL)
14925                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
14926                 last_hops_constr.data[l] = arr_conv_11_conv;
14927         }
14928         LDKLogger logger_conv = *(LDKLogger*)logger;
14929         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14930         *ret_conv = get_route(our_node_id_ref, &network_conv, target_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
14931         FREE(first_hops_constr.data);
14932         return (long)ret_conv;
14933 }
14934
14935 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_ptr) {
14936         LDKNetworkGraph this_ptr_conv;
14937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14938         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14939         NetworkGraph_free(this_ptr_conv);
14940 }
14941
14942 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_ptr) {
14943         LDKLockedNetworkGraph this_ptr_conv;
14944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14945         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14946         LockedNetworkGraph_free(this_ptr_conv);
14947 }
14948
14949 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_ptr) {
14950         LDKNetGraphMsgHandler this_ptr_conv;
14951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14952         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14953         NetGraphMsgHandler_free(this_ptr_conv);
14954 }
14955
14956 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
14957         LDKThirtyTwoBytes genesis_hash_ref;
14958         CHECK(*((uint32_t*)genesis_hash) == 32);
14959         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
14960         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14961         LDKLogger logger_conv = *(LDKLogger*)logger;
14962         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
14963         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14964         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14965         long ret_ref = (long)ret_var.inner;
14966         if (ret_var.is_owned) {
14967                 ret_ref |= 1;
14968         }
14969         return ret_ref;
14970 }
14971
14972 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
14973         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14974         LDKLogger logger_conv = *(LDKLogger*)logger;
14975         LDKNetworkGraph network_graph_conv;
14976         network_graph_conv.inner = (void*)(network_graph & (~1));
14977         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
14978         // Warning: we may need a move here but can't clone!
14979         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
14980         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14981         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14982         long ret_ref = (long)ret_var.inner;
14983         if (ret_var.is_owned) {
14984                 ret_ref |= 1;
14985         }
14986         return ret_ref;
14987 }
14988
14989 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
14990         LDKNetGraphMsgHandler this_arg_conv;
14991         this_arg_conv.inner = (void*)(this_arg & (~1));
14992         this_arg_conv.is_owned = false;
14993         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
14994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14996         long ret_ref = (long)ret_var.inner;
14997         if (ret_var.is_owned) {
14998                 ret_ref |= 1;
14999         }
15000         return ret_ref;
15001 }
15002
15003 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
15004         LDKLockedNetworkGraph this_arg_conv;
15005         this_arg_conv.inner = (void*)(this_arg & (~1));
15006         this_arg_conv.is_owned = false;
15007         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
15008         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15009         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15010         long ret_ref = (long)ret_var.inner;
15011         if (ret_var.is_owned) {
15012                 ret_ref |= 1;
15013         }
15014         return ret_ref;
15015 }
15016
15017 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
15018         LDKNetGraphMsgHandler this_arg_conv;
15019         this_arg_conv.inner = (void*)(this_arg & (~1));
15020         this_arg_conv.is_owned = false;
15021         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
15022         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
15023         return (long)ret;
15024 }
15025
15026 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
15027         LDKNetGraphMsgHandler this_arg_conv;
15028         this_arg_conv.inner = (void*)(this_arg & (~1));
15029         this_arg_conv.is_owned = false;
15030         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
15031         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
15032         return (long)ret;
15033 }
15034
15035 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_ptr) {
15036         LDKDirectionalChannelInfo this_ptr_conv;
15037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15038         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15039         DirectionalChannelInfo_free(this_ptr_conv);
15040 }
15041
15042 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
15043         LDKDirectionalChannelInfo this_ptr_conv;
15044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15045         this_ptr_conv.is_owned = false;
15046         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
15047         return ret_val;
15048 }
15049
15050 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
15051         LDKDirectionalChannelInfo this_ptr_conv;
15052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15053         this_ptr_conv.is_owned = false;
15054         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
15055 }
15056
15057 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
15058         LDKDirectionalChannelInfo this_ptr_conv;
15059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15060         this_ptr_conv.is_owned = false;
15061         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
15062         return ret_val;
15063 }
15064
15065 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
15066         LDKDirectionalChannelInfo this_ptr_conv;
15067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15068         this_ptr_conv.is_owned = false;
15069         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
15070 }
15071
15072 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
15073         LDKDirectionalChannelInfo this_ptr_conv;
15074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15075         this_ptr_conv.is_owned = false;
15076         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
15077         return ret_val;
15078 }
15079
15080 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
15081         LDKDirectionalChannelInfo this_ptr_conv;
15082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15083         this_ptr_conv.is_owned = false;
15084         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
15085 }
15086
15087 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
15088         LDKDirectionalChannelInfo this_ptr_conv;
15089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15090         this_ptr_conv.is_owned = false;
15091         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
15092         return ret_val;
15093 }
15094
15095 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
15096         LDKDirectionalChannelInfo this_ptr_conv;
15097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15098         this_ptr_conv.is_owned = false;
15099         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
15100 }
15101
15102 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
15103         LDKDirectionalChannelInfo this_ptr_conv;
15104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15105         this_ptr_conv.is_owned = false;
15106         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
15107         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15108         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15109         long ret_ref = (long)ret_var.inner;
15110         if (ret_var.is_owned) {
15111                 ret_ref |= 1;
15112         }
15113         return ret_ref;
15114 }
15115
15116 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
15117         LDKDirectionalChannelInfo this_ptr_conv;
15118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15119         this_ptr_conv.is_owned = false;
15120         LDKRoutingFees val_conv;
15121         val_conv.inner = (void*)(val & (~1));
15122         val_conv.is_owned = (val & 1) || (val == 0);
15123         if (val_conv.inner != NULL)
15124                 val_conv = RoutingFees_clone(&val_conv);
15125         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
15126 }
15127
15128 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
15129         LDKDirectionalChannelInfo this_ptr_conv;
15130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15131         this_ptr_conv.is_owned = false;
15132         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
15133         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15134         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15135         long ret_ref = (long)ret_var.inner;
15136         if (ret_var.is_owned) {
15137                 ret_ref |= 1;
15138         }
15139         return ret_ref;
15140 }
15141
15142 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
15143         LDKDirectionalChannelInfo this_ptr_conv;
15144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15145         this_ptr_conv.is_owned = false;
15146         LDKChannelUpdate val_conv;
15147         val_conv.inner = (void*)(val & (~1));
15148         val_conv.is_owned = (val & 1) || (val == 0);
15149         if (val_conv.inner != NULL)
15150                 val_conv = ChannelUpdate_clone(&val_conv);
15151         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
15152 }
15153
15154 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
15155         LDKDirectionalChannelInfo obj_conv;
15156         obj_conv.inner = (void*)(obj & (~1));
15157         obj_conv.is_owned = false;
15158         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
15159         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15160         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15161         CVec_u8Z_free(arg_var);
15162         return arg_arr;
15163 }
15164
15165 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
15166         LDKu8slice ser_ref;
15167         ser_ref.datalen = *((uint32_t*)ser);
15168         ser_ref.data = (int8_t*)(ser + 4);
15169         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_read(ser_ref);
15170         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15171         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15172         long ret_ref = (long)ret_var.inner;
15173         if (ret_var.is_owned) {
15174                 ret_ref |= 1;
15175         }
15176         return ret_ref;
15177 }
15178
15179 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_ptr) {
15180         LDKChannelInfo this_ptr_conv;
15181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15182         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15183         ChannelInfo_free(this_ptr_conv);
15184 }
15185
15186 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
15187         LDKChannelInfo this_ptr_conv;
15188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15189         this_ptr_conv.is_owned = false;
15190         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
15191         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15192         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15193         long ret_ref = (long)ret_var.inner;
15194         if (ret_var.is_owned) {
15195                 ret_ref |= 1;
15196         }
15197         return ret_ref;
15198 }
15199
15200 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
15201         LDKChannelInfo this_ptr_conv;
15202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15203         this_ptr_conv.is_owned = false;
15204         LDKChannelFeatures val_conv;
15205         val_conv.inner = (void*)(val & (~1));
15206         val_conv.is_owned = (val & 1) || (val == 0);
15207         // Warning: we may need a move here but can't clone!
15208         ChannelInfo_set_features(&this_ptr_conv, val_conv);
15209 }
15210
15211 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
15212         LDKChannelInfo this_ptr_conv;
15213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15214         this_ptr_conv.is_owned = false;
15215         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15216         memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
15217         return arg_arr;
15218 }
15219
15220 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
15221         LDKChannelInfo this_ptr_conv;
15222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15223         this_ptr_conv.is_owned = false;
15224         LDKPublicKey val_ref;
15225         CHECK(*((uint32_t*)val) == 33);
15226         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15227         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
15228 }
15229
15230 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
15231         LDKChannelInfo this_ptr_conv;
15232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15233         this_ptr_conv.is_owned = false;
15234         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
15235         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15236         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15237         long ret_ref = (long)ret_var.inner;
15238         if (ret_var.is_owned) {
15239                 ret_ref |= 1;
15240         }
15241         return ret_ref;
15242 }
15243
15244 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
15245         LDKChannelInfo this_ptr_conv;
15246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15247         this_ptr_conv.is_owned = false;
15248         LDKDirectionalChannelInfo val_conv;
15249         val_conv.inner = (void*)(val & (~1));
15250         val_conv.is_owned = (val & 1) || (val == 0);
15251         // Warning: we may need a move here but can't clone!
15252         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
15253 }
15254
15255 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
15256         LDKChannelInfo this_ptr_conv;
15257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15258         this_ptr_conv.is_owned = false;
15259         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15260         memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
15261         return arg_arr;
15262 }
15263
15264 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
15265         LDKChannelInfo this_ptr_conv;
15266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15267         this_ptr_conv.is_owned = false;
15268         LDKPublicKey val_ref;
15269         CHECK(*((uint32_t*)val) == 33);
15270         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15271         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
15272 }
15273
15274 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
15275         LDKChannelInfo this_ptr_conv;
15276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15277         this_ptr_conv.is_owned = false;
15278         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
15279         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15280         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15281         long ret_ref = (long)ret_var.inner;
15282         if (ret_var.is_owned) {
15283                 ret_ref |= 1;
15284         }
15285         return ret_ref;
15286 }
15287
15288 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
15289         LDKChannelInfo this_ptr_conv;
15290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15291         this_ptr_conv.is_owned = false;
15292         LDKDirectionalChannelInfo val_conv;
15293         val_conv.inner = (void*)(val & (~1));
15294         val_conv.is_owned = (val & 1) || (val == 0);
15295         // Warning: we may need a move here but can't clone!
15296         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
15297 }
15298
15299 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
15300         LDKChannelInfo this_ptr_conv;
15301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15302         this_ptr_conv.is_owned = false;
15303         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
15304         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15305         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15306         long ret_ref = (long)ret_var.inner;
15307         if (ret_var.is_owned) {
15308                 ret_ref |= 1;
15309         }
15310         return ret_ref;
15311 }
15312
15313 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15314         LDKChannelInfo this_ptr_conv;
15315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15316         this_ptr_conv.is_owned = false;
15317         LDKChannelAnnouncement val_conv;
15318         val_conv.inner = (void*)(val & (~1));
15319         val_conv.is_owned = (val & 1) || (val == 0);
15320         if (val_conv.inner != NULL)
15321                 val_conv = ChannelAnnouncement_clone(&val_conv);
15322         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
15323 }
15324
15325 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
15326         LDKChannelInfo obj_conv;
15327         obj_conv.inner = (void*)(obj & (~1));
15328         obj_conv.is_owned = false;
15329         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
15330         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15331         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15332         CVec_u8Z_free(arg_var);
15333         return arg_arr;
15334 }
15335
15336 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
15337         LDKu8slice ser_ref;
15338         ser_ref.datalen = *((uint32_t*)ser);
15339         ser_ref.data = (int8_t*)(ser + 4);
15340         LDKChannelInfo ret_var = ChannelInfo_read(ser_ref);
15341         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15342         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15343         long ret_ref = (long)ret_var.inner;
15344         if (ret_var.is_owned) {
15345                 ret_ref |= 1;
15346         }
15347         return ret_ref;
15348 }
15349
15350 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_ptr) {
15351         LDKRoutingFees this_ptr_conv;
15352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15353         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15354         RoutingFees_free(this_ptr_conv);
15355 }
15356
15357 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
15358         LDKRoutingFees orig_conv;
15359         orig_conv.inner = (void*)(orig & (~1));
15360         orig_conv.is_owned = false;
15361         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
15362         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15363         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15364         long ret_ref = (long)ret_var.inner;
15365         if (ret_var.is_owned) {
15366                 ret_ref |= 1;
15367         }
15368         return ret_ref;
15369 }
15370
15371 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
15372         LDKRoutingFees this_ptr_conv;
15373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15374         this_ptr_conv.is_owned = false;
15375         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
15376         return ret_val;
15377 }
15378
15379 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
15380         LDKRoutingFees this_ptr_conv;
15381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15382         this_ptr_conv.is_owned = false;
15383         RoutingFees_set_base_msat(&this_ptr_conv, val);
15384 }
15385
15386 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
15387         LDKRoutingFees this_ptr_conv;
15388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15389         this_ptr_conv.is_owned = false;
15390         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
15391         return ret_val;
15392 }
15393
15394 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
15395         LDKRoutingFees this_ptr_conv;
15396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15397         this_ptr_conv.is_owned = false;
15398         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
15399 }
15400
15401 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
15402         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
15403         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15404         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15405         long ret_ref = (long)ret_var.inner;
15406         if (ret_var.is_owned) {
15407                 ret_ref |= 1;
15408         }
15409         return ret_ref;
15410 }
15411
15412 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
15413         LDKu8slice ser_ref;
15414         ser_ref.datalen = *((uint32_t*)ser);
15415         ser_ref.data = (int8_t*)(ser + 4);
15416         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15417         *ret_conv = RoutingFees_read(ser_ref);
15418         return (long)ret_conv;
15419 }
15420
15421 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
15422         LDKRoutingFees obj_conv;
15423         obj_conv.inner = (void*)(obj & (~1));
15424         obj_conv.is_owned = false;
15425         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
15426         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15427         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15428         CVec_u8Z_free(arg_var);
15429         return arg_arr;
15430 }
15431
15432 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_ptr) {
15433         LDKNodeAnnouncementInfo this_ptr_conv;
15434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15435         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15436         NodeAnnouncementInfo_free(this_ptr_conv);
15437 }
15438
15439 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
15440         LDKNodeAnnouncementInfo this_ptr_conv;
15441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15442         this_ptr_conv.is_owned = false;
15443         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
15444         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15445         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15446         long ret_ref = (long)ret_var.inner;
15447         if (ret_var.is_owned) {
15448                 ret_ref |= 1;
15449         }
15450         return ret_ref;
15451 }
15452
15453 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
15454         LDKNodeAnnouncementInfo this_ptr_conv;
15455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15456         this_ptr_conv.is_owned = false;
15457         LDKNodeFeatures val_conv;
15458         val_conv.inner = (void*)(val & (~1));
15459         val_conv.is_owned = (val & 1) || (val == 0);
15460         // Warning: we may need a move here but can't clone!
15461         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
15462 }
15463
15464 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
15465         LDKNodeAnnouncementInfo this_ptr_conv;
15466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15467         this_ptr_conv.is_owned = false;
15468         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
15469         return ret_val;
15470 }
15471
15472 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
15473         LDKNodeAnnouncementInfo this_ptr_conv;
15474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15475         this_ptr_conv.is_owned = false;
15476         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
15477 }
15478
15479 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
15480         LDKNodeAnnouncementInfo this_ptr_conv;
15481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15482         this_ptr_conv.is_owned = false;
15483         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
15484         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
15485         return ret_arr;
15486 }
15487
15488 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
15489         LDKNodeAnnouncementInfo this_ptr_conv;
15490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15491         this_ptr_conv.is_owned = false;
15492         LDKThreeBytes val_ref;
15493         CHECK(*((uint32_t*)val) == 3);
15494         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
15495         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
15496 }
15497
15498 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
15499         LDKNodeAnnouncementInfo this_ptr_conv;
15500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15501         this_ptr_conv.is_owned = false;
15502         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15503         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
15504         return ret_arr;
15505 }
15506
15507 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
15508         LDKNodeAnnouncementInfo this_ptr_conv;
15509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15510         this_ptr_conv.is_owned = false;
15511         LDKThirtyTwoBytes val_ref;
15512         CHECK(*((uint32_t*)val) == 32);
15513         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15514         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
15515 }
15516
15517 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
15518         LDKNodeAnnouncementInfo this_ptr_conv;
15519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15520         this_ptr_conv.is_owned = false;
15521         LDKCVec_NetAddressZ val_constr;
15522         val_constr.datalen = *((uint32_t*)val);
15523         if (val_constr.datalen > 0)
15524                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15525         else
15526                 val_constr.data = NULL;
15527         uint32_t* val_vals = (uint32_t*)(val + 4);
15528         for (size_t m = 0; m < val_constr.datalen; m++) {
15529                 uint32_t arr_conv_12 = val_vals[m];
15530                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
15531                 FREE((void*)arr_conv_12);
15532                 val_constr.data[m] = arr_conv_12_conv;
15533         }
15534         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
15535 }
15536
15537 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
15538         LDKNodeAnnouncementInfo this_ptr_conv;
15539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15540         this_ptr_conv.is_owned = false;
15541         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
15542         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15543         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15544         long ret_ref = (long)ret_var.inner;
15545         if (ret_var.is_owned) {
15546                 ret_ref |= 1;
15547         }
15548         return ret_ref;
15549 }
15550
15551 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15552         LDKNodeAnnouncementInfo this_ptr_conv;
15553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15554         this_ptr_conv.is_owned = false;
15555         LDKNodeAnnouncement val_conv;
15556         val_conv.inner = (void*)(val & (~1));
15557         val_conv.is_owned = (val & 1) || (val == 0);
15558         if (val_conv.inner != NULL)
15559                 val_conv = NodeAnnouncement_clone(&val_conv);
15560         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
15561 }
15562
15563 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) {
15564         LDKNodeFeatures features_arg_conv;
15565         features_arg_conv.inner = (void*)(features_arg & (~1));
15566         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15567         // Warning: we may need a move here but can't clone!
15568         LDKThreeBytes rgb_arg_ref;
15569         CHECK(*((uint32_t*)rgb_arg) == 3);
15570         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
15571         LDKThirtyTwoBytes alias_arg_ref;
15572         CHECK(*((uint32_t*)alias_arg) == 32);
15573         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
15574         LDKCVec_NetAddressZ addresses_arg_constr;
15575         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
15576         if (addresses_arg_constr.datalen > 0)
15577                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15578         else
15579                 addresses_arg_constr.data = NULL;
15580         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
15581         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
15582                 uint32_t arr_conv_12 = addresses_arg_vals[m];
15583                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
15584                 FREE((void*)arr_conv_12);
15585                 addresses_arg_constr.data[m] = arr_conv_12_conv;
15586         }
15587         LDKNodeAnnouncement announcement_message_arg_conv;
15588         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
15589         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
15590         if (announcement_message_arg_conv.inner != NULL)
15591                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
15592         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
15593         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15594         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15595         long ret_ref = (long)ret_var.inner;
15596         if (ret_var.is_owned) {
15597                 ret_ref |= 1;
15598         }
15599         return ret_ref;
15600 }
15601
15602 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
15603         LDKNodeAnnouncementInfo obj_conv;
15604         obj_conv.inner = (void*)(obj & (~1));
15605         obj_conv.is_owned = false;
15606         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
15607         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15608         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15609         CVec_u8Z_free(arg_var);
15610         return arg_arr;
15611 }
15612
15613 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_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_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15618         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
15619         return (long)ret_conv;
15620 }
15621
15622 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_ptr) {
15623         LDKNodeInfo this_ptr_conv;
15624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15625         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15626         NodeInfo_free(this_ptr_conv);
15627 }
15628
15629 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
15630         LDKNodeInfo this_ptr_conv;
15631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15632         this_ptr_conv.is_owned = false;
15633         LDKCVec_u64Z val_constr;
15634         val_constr.datalen = *((uint32_t*)val);
15635         if (val_constr.datalen > 0)
15636                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15637         else
15638                 val_constr.data = NULL;
15639         int64_t* val_vals = (int64_t*)(val + 4);
15640         for (size_t i = 0; i < val_constr.datalen; i++) {
15641                 int64_t arr_conv_8 = val_vals[i];
15642                 val_constr.data[i] = arr_conv_8;
15643         }
15644         NodeInfo_set_channels(&this_ptr_conv, val_constr);
15645 }
15646
15647 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
15648         LDKNodeInfo this_ptr_conv;
15649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15650         this_ptr_conv.is_owned = false;
15651         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
15652         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15653         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15654         long ret_ref = (long)ret_var.inner;
15655         if (ret_var.is_owned) {
15656                 ret_ref |= 1;
15657         }
15658         return ret_ref;
15659 }
15660
15661 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
15662         LDKNodeInfo this_ptr_conv;
15663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15664         this_ptr_conv.is_owned = false;
15665         LDKRoutingFees val_conv;
15666         val_conv.inner = (void*)(val & (~1));
15667         val_conv.is_owned = (val & 1) || (val == 0);
15668         if (val_conv.inner != NULL)
15669                 val_conv = RoutingFees_clone(&val_conv);
15670         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
15671 }
15672
15673 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
15674         LDKNodeInfo this_ptr_conv;
15675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15676         this_ptr_conv.is_owned = false;
15677         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
15678         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15679         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15680         long ret_ref = (long)ret_var.inner;
15681         if (ret_var.is_owned) {
15682                 ret_ref |= 1;
15683         }
15684         return ret_ref;
15685 }
15686
15687 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
15688         LDKNodeInfo this_ptr_conv;
15689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15690         this_ptr_conv.is_owned = false;
15691         LDKNodeAnnouncementInfo val_conv;
15692         val_conv.inner = (void*)(val & (~1));
15693         val_conv.is_owned = (val & 1) || (val == 0);
15694         // Warning: we may need a move here but can't clone!
15695         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
15696 }
15697
15698 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
15699         LDKCVec_u64Z channels_arg_constr;
15700         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
15701         if (channels_arg_constr.datalen > 0)
15702                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15703         else
15704                 channels_arg_constr.data = NULL;
15705         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
15706         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
15707                 int64_t arr_conv_8 = channels_arg_vals[i];
15708                 channels_arg_constr.data[i] = arr_conv_8;
15709         }
15710         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
15711         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
15712         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
15713         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
15714                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
15715         LDKNodeAnnouncementInfo announcement_info_arg_conv;
15716         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
15717         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
15718         // Warning: we may need a move here but can't clone!
15719         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
15720         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15721         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15722         long ret_ref = (long)ret_var.inner;
15723         if (ret_var.is_owned) {
15724                 ret_ref |= 1;
15725         }
15726         return ret_ref;
15727 }
15728
15729 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
15730         LDKNodeInfo obj_conv;
15731         obj_conv.inner = (void*)(obj & (~1));
15732         obj_conv.is_owned = false;
15733         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
15734         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15735         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15736         CVec_u8Z_free(arg_var);
15737         return arg_arr;
15738 }
15739
15740 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
15741         LDKu8slice ser_ref;
15742         ser_ref.datalen = *((uint32_t*)ser);
15743         ser_ref.data = (int8_t*)(ser + 4);
15744         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15745         *ret_conv = NodeInfo_read(ser_ref);
15746         return (long)ret_conv;
15747 }
15748
15749 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
15750         LDKNetworkGraph obj_conv;
15751         obj_conv.inner = (void*)(obj & (~1));
15752         obj_conv.is_owned = false;
15753         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
15754         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15755         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15756         CVec_u8Z_free(arg_var);
15757         return arg_arr;
15758 }
15759
15760 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
15761         LDKu8slice ser_ref;
15762         ser_ref.datalen = *((uint32_t*)ser);
15763         ser_ref.data = (int8_t*)(ser + 4);
15764         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15765         *ret_conv = NetworkGraph_read(ser_ref);
15766         return (long)ret_conv;
15767 }
15768
15769 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
15770         LDKThirtyTwoBytes genesis_hash_ref;
15771         CHECK(*((uint32_t*)genesis_hash) == 32);
15772         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
15773         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
15774         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15775         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15776         long ret_ref = (long)ret_var.inner;
15777         if (ret_var.is_owned) {
15778                 ret_ref |= 1;
15779         }
15780         return ret_ref;
15781 }
15782
15783 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
15784         LDKNetworkGraph this_arg_conv;
15785         this_arg_conv.inner = (void*)(this_arg & (~1));
15786         this_arg_conv.is_owned = false;
15787         LDKNodeAnnouncement msg_conv;
15788         msg_conv.inner = (void*)(msg & (~1));
15789         msg_conv.is_owned = false;
15790         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15791         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
15792         return (long)ret_conv;
15793 }
15794
15795 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
15796         LDKNetworkGraph this_arg_conv;
15797         this_arg_conv.inner = (void*)(this_arg & (~1));
15798         this_arg_conv.is_owned = false;
15799         LDKUnsignedNodeAnnouncement msg_conv;
15800         msg_conv.inner = (void*)(msg & (~1));
15801         msg_conv.is_owned = false;
15802         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15803         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
15804         return (long)ret_conv;
15805 }
15806
15807 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15808         LDKNetworkGraph this_arg_conv;
15809         this_arg_conv.inner = (void*)(this_arg & (~1));
15810         this_arg_conv.is_owned = false;
15811         LDKChannelAnnouncement msg_conv;
15812         msg_conv.inner = (void*)(msg & (~1));
15813         msg_conv.is_owned = false;
15814         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15815         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15816         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15817         return (long)ret_conv;
15818 }
15819
15820 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15821         LDKNetworkGraph this_arg_conv;
15822         this_arg_conv.inner = (void*)(this_arg & (~1));
15823         this_arg_conv.is_owned = false;
15824         LDKUnsignedChannelAnnouncement msg_conv;
15825         msg_conv.inner = (void*)(msg & (~1));
15826         msg_conv.is_owned = false;
15827         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15828         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15829         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15830         return (long)ret_conv;
15831 }
15832
15833 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
15834         LDKNetworkGraph this_arg_conv;
15835         this_arg_conv.inner = (void*)(this_arg & (~1));
15836         this_arg_conv.is_owned = false;
15837         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
15838 }
15839
15840 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
15841         LDKNetworkGraph this_arg_conv;
15842         this_arg_conv.inner = (void*)(this_arg & (~1));
15843         this_arg_conv.is_owned = false;
15844         LDKChannelUpdate msg_conv;
15845         msg_conv.inner = (void*)(msg & (~1));
15846         msg_conv.is_owned = false;
15847         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15848         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
15849         return (long)ret_conv;
15850 }
15851
15852 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
15853         LDKNetworkGraph this_arg_conv;
15854         this_arg_conv.inner = (void*)(this_arg & (~1));
15855         this_arg_conv.is_owned = false;
15856         LDKUnsignedChannelUpdate msg_conv;
15857         msg_conv.inner = (void*)(msg & (~1));
15858         msg_conv.is_owned = false;
15859         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15860         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
15861         return (long)ret_conv;
15862 }
15863